Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need some help with some Bash scripts 1. Suppose you wanted to change the suffix of all your .c files to .c. Doing my ..C.c

image text in transcribed

Need some help with some Bash scripts

1. Suppose you wanted to change the suffix of all your .c files to .c. Doing my ..C.c won't work (why? think about what exactly the line expands to). Write a script for that purpose. 2. Write a one-line script that finds files whose names have at least one whitespace (see find) 3. Write a script that does the same as the previous one, and then renames the files by replacing the whitespace with an underscore. 4. Substitute the whitespaces in the sentence "To be or not to be" with underscores. Use echo and the pipeline to generate the sentence and pass it to standard input. Show how to perform the substitution both with sed and with tr. Since whitespace is a metacharacter in the shell, show how to handle it with all three quoting mechanisms (escape character, single quotes, double quotes). 5. Create a text file with 5 lines. Insert a line containing the string And the Oscar goes to... exactly at line number 3, and in doing so remove the previous line (see sed). 6. Create a text file with 5 lines. Insert a line containing the string And the Oscar goes to... exactly at line number 3, without replacing the previous line (see sed). 7. Suppose you want to write the same letter to many people except that you want each letter addressed to the senders personally. This can be created using a shell script. Put the names of the recipients (one per line) in a file called names. Create a textfile called template which has the string NAME wherever you want the person's name to appear (e.g., Dear NAME, ...). Finally, write a script that produces one file per name (call each file using the person's name with suffix .txt), containing the personalized letter obtained from the template file (use sed). 8. Write a script that takes a string as command line argument corresponding to a filename, sorts the lines of the input file in reverse alphabetical order, and stores the result to a file whose name has in addition the suffix .sorted (use sort). Test your script on the file names created before

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions