Linux BASH shell command help! What commands would I use for these? Using a loop
ID: 3599625 • Letter: L
Question
Linux BASH shell command help! What commands would I use for these?
Using a loop, take each different word in file1 and determine how many words in the dictionary (use one of your choice from those described in lecture notes) begin with that word as a prefix.
For these problems, create and use a new subdirectory called 'projectB'. 1. Using a command or script, create 45 files in projectB using filenames consisting of the 45 words in the dictionary (/home/SRUNET/david.dailey/words) that end in 'ort'. 2. Use a single command to remove all files with names started with s inside 'projectB'. 3. There are 598 words ending in 'ort' in /usr/share/dict/words. Use a command to determine how many of these begin with lower case letters. 4. There are 865 words in /home/SRUNET/david.dailey/words that end in 'ate'. How many begin with each of the letters a, t and e? Provide an example of each. 5. There are 808 words in /home/SRUNET/david.dailey/words that end in 'ity' including these: $ grep ity$ $w|head -3 ability abnormality abnormity Exactly 20 of those words remain words (in that dictionary) after changing the 'ity' to ify' including these: clarify (clarity) complexify (complexity) deify (deity) dignify (dignity) diversify (diversity) identify (identity) Write a command which finds exactly those 20 words.
1. In the file $w=/home/SRUNET/david.dailey/words, the command grep -c ism$ $w demonstrates that 325 words in that file end with 'ism.' The ending 'tic' occurs more frequently, appearing at the end of 336 words. How can you find the 14 three letter endings that serve as endings to more words than 'ism'? As always, show commands used, the output found and steps used to verify correctness. 2. The file s=/home/SRUNET/david.dailey/data/es.txt contains word frequency lists (from Invoke IT Limited) for Spanish language text (apparently sampled from Internet social media). Not all of the 535232 words contained therein are legitimate parts of Spanish vocabulary. You may need to set your putty language settings (under Change Settings/Window/Translation) to UTF-8 to be able to see the characters as expected. Among the 100,000 most frequently used words in that list (head -100000 $s) find which 30 characters (Spanish letters) begin words most often. Find the commands to output just those 30 characters (separated by spaces instead of carriage returns).
Explanation / Answer
Hey!
I am giving you some solution on my understnding of what you ar looking for.
1. // for creating a folder projectB
mkdir 'projectB'
2. // for creating 45 files of the 45 words written in /home/SRUNET/david.dailey/words.
while read name
do
touch "./projectb/$name" # This will create files
done < '/home/SRUNET/david.dailey/words' # it will take input from the file words
3. // to remove all file start with s
find ./projectB -type f -name 's*' -exec rm {} ; # It will remove all file start with s in projectB folder
4. // finding the words strat with lowercase and ends with ort under the file words.
Thanks.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.