Question

In: Computer Science

I am a student taking an introductory Unix / LInux shell programming course and need some...

I am a student taking an introductory Unix / LInux shell programming course and need some help with an assignment.

Using the file CISED as input, write the sed command to do the following:

Change 2 or more occurrences of g to a single g

Add > to beginning of any line that begins with CIS132

Add < to the end of any line that ends in Tux or tux

Replace any five to eight digit number with XX

For every line that begins with CIS132, place the first 6 characters in the line at the end of the line and the last three characters at the beginning of the line. Leave the characters in between these characters as they were.

Change any non alphanumeric character to &

For any line that begins with CIS132 place the entire line inside of double quotes.

Thanks for your help.

Solutions

Expert Solution

Please find the following sed commands to edit the file.

Change 2 or more occurrences of g to a single g

sed 's/g\{2,\}/g/g' <inputfile

Add > to beginning of any line that begins with CIS132

sed 's/^CIS132/\<CIS132/g' <inputfile

Add < to the end of any line that ends in Tux or tux

sed 's/Tux$/Tux\>/g' <inputfile

sed 's/tux$/tux\>/g' <inputfile

Replace any five to eight digit number with XX

sed 's/[0-9]\{5,8\}/XX/g' <inputfile

For every line that begins with CIS132, place the first 6 characters in the line at the end of the line and the last three characters at the beginning of the line. Leave the characters in between these characters as they were.

sed 's/^\(CIS132\)\(.*\)\(...\)$/\3\2\1/' <inputfile

Change any non alphanumeric character to &

sed 's/[^a-zA-Z0-9]/\&/g' <sedFile

For any line that begins with CIS132 place the entire line inside of double quotes.

sed 's/^\(CIS132.*\)/"\1"/' <inputfile

Screen Shot:


Related Solutions

When programming in the Unix/Linux shell, short-circuit evaluation of an expression is a standard way to...
When programming in the Unix/Linux shell, short-circuit evaluation of an expression is a standard way to execute a second command ONLY IF the first command was successful. How does this work? What is a ternary operator? When should it be used and when should it be avoided? We perform a hand trace of a C program to validate what?
I am a student taking python programming. Can this problem be modified using the define main...
I am a student taking python programming. Can this problem be modified using the define main method, def main()? #Define showExspenses function def showExpenses(loan,insure,gas,oil,tyres,maintenance): expense=loan+insure+gas+oil+tyres+maintenance #Print monthly and yearly automobile operating expenses print("\nTotal Monthly expenses for operating expenses you entered = ",expense) print(f"\nTotal Yearly expenses for operating expenses you entered = 12 *",expense,f"= {expense*12:,}") #yearly expenses loan=int(input("Enter Loan :")) insure=int(input("Enter Insurance :")) gas=int(input("Enter Gas :")) oil=int(input("Enter Oil :")) tyres=int(input("Enter Tyres :")) maintenance=int(input("Enter Maintenance:")) showExpenses(loan,insure,gas,oil,tyres,maintenance)
I am a doctorate student (Educational Leadership) taking a course in School Finance. Please give me...
I am a doctorate student (Educational Leadership) taking a course in School Finance. Please give me questions that I can ask in an interview with a CFO/Treasurer of a school or university finance officer. Thanks.
a) b) c) Compare and contrast systems programming in Windows as against systems programming in Unix/Linux....
a) b) c) Compare and contrast systems programming in Windows as against systems programming in Unix/Linux. CR, 8 Explain the term structured exception handling (SEH) as used in systems programming and give a practical example of how it can be used to handle errors in a block of code. AP, 7 Write a C/C++ system program to delete an unwanted file in the Windows file system. Compile and run the program and copy the source code into your answer booklet....
Linux Directories, File Properties, and the File System in C Understanding Unix/Linux Programming Your version of...
Linux Directories, File Properties, and the File System in C Understanding Unix/Linux Programming Your version of mv command The mv command is more than just a wrapper around the rename system call. Write a version of mv that accepts two argument. The first argument must be the name of a file, and the second argument may be the name of a file or the name of a directory. If the destination is the name of a directory, then mv moves...
Hello i am working on an assignment for my programming course in JAVA. The following is...
Hello i am working on an assignment for my programming course in JAVA. The following is the assignment: In main, first ask the user for their name, and read the name into a String variable. Then, using their name, ask for a temperature in farenheit, and read that value in. Calculate and print the equivalent celsius, with output something like Bob, your 32 degrees farenheit would be 0 degrees celsius Look up the celsius to farenheit conversion if you do...
UNIX/LINUX LAB (1) Review the sample shell program (tryShell.c), and compile/run the program (tryShell) with the...
UNIX/LINUX LAB (1) Review the sample shell program (tryShell.c), and compile/run the program (tryShell) with the following commands, and at the end, use CTRL+C to terminate the program: ls ls -l tryShell* date whoami hostname uname -a ctrl+C    (2) Run the program (tryShell) with "time -p" with a few commands: time -p ./tryShell (3) Edit the program (tryShell.c) so that it will exit (terminate the program) when the input command string is "exit" try shell.c code at bottom //////////// #include...
Perl is a programming language that can be used on Linux. Write a Perl shell script...
Perl is a programming language that can be used on Linux. Write a Perl shell script named phone.pl that prompts the user to enter first or last or any portion of person’s name, so that can be found the appropriate entry in the phone directory file called “phones”. If the user tries to enter name as the argument on the command line, he/she will get a warning message “You need to provide name when prompted by this script!” If the...
Question 1: A student in an introductory statistics course investigated if there is evidence that the...
Question 1: A student in an introductory statistics course investigated if there is evidence that the proportion of milk chocolate M&M's that are green differs from the proportion of dark chocolate M&M's that are green. She purchased a bag of each variety, and her data are summarized in the following table. Green Not Green Total Milk Chocolate 8 33 41 Dark Chocolate 4 38 42 Total 12 71 83                          c. Estimate the p-value using the randomization distribution and show...
I am doing this assignment using Kali Linux (COMPUTER SECURITY) I need to use crunch to...
I am doing this assignment using Kali Linux (COMPUTER SECURITY) I need to use crunch to generate all words which start with a lowercase letter, and then "YOURNAME(uppercase letter)", and then end with 2 digits. (e.g., "aIMAN23") I just need the screenshot of the crunch commands to follow. Using John the Ripper (In Kali Linux) I need the john command so I can use to Break test user's password: test:$6$fFEVS9TQoNU/aQsm$hxv5R1cSxwENUcdjxlI9WwbF8F3uruxAlDUf0vXaOAJRZnWhxr7zzLlFNJPGvc1pTdVV.lsuQkQh3mSjpy6SG/:18535:::::: I just need the screenshot to follow.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT