Question

In: Computer Science

this is bash scripting. a. Explain the difference between grep and egrep? b. Write a command...

this is bash scripting.

a. Explain the difference between grep and egrep?

b. Write a command to list files where third letter is x or y?

c. Write command to remove array element with id 5

Solutions

Expert Solution

Answer a)
grep stands for Global Regular Expressions Print but egrep stands for Extended Global Regular Expressions Print

When we use grep for pattern search for the symbols cannot be done directly we have to use the backslash but in egrep the symbols are the meta characters which we can use directly without backslash.

grep -E is same as egrep

screenshot

Answer b)

ls ??[xy]*

here ?? means any character for the first two characters and for the third letter [xy] means either x or y then * means any character after x or y.

Screenshot

Answer c)

unset arr1[5]

By the unset command we can remove the array element in a shell script.


Related Solutions

linux Using the grep or egrep commands, what would be the full command (including regular expression)...
linux Using the grep or egrep commands, what would be the full command (including regular expression) to view only the lines in the file /boot/grub/grub.cfg that DO NOT begin with a hashtag (the # sign). In other words, what would be the command to print all the lines in this file that do not begin with this character.
this is bash scripting. a. Write a shell script that adds an extension “.deb” to all...
this is bash scripting. a. Write a shell script that adds an extension “.deb” to all the files in a directory. b. Write a command sequence or a script to insert a line “GHIJKLM” at every 10th line of a file? c. Write a bash command or script to find all the files modified in less than 5 days and print the record count of each.
Open a terminal a) Type ps –ef | grep bash. Record the PID. b) Open a...
Open a terminal a) Type ps –ef | grep bash. Record the PID. b) Open a second terminal (leaving the first active) and type kill –l to see the available kill signals c) Type kill -2 (# of the recorded PID). Did the first terminal session close? d) Type kill -3 (# of the recorded PID). Did the first terminal session close? e) Type kill -15 (# of the recorded PID). Did the first terminal session close? f) Type kill...
Here are the tasks for this assignment: 1. Write a bash command line to determine if...
Here are the tasks for this assignment: 1. Write a bash command line to determine if the server 'syccuxfs01.pcc.edu' is reachable from the syccuxas01.pcc.edu server. 2. As you have read, TCP/IP messages are passed from one device to another until the message reaches its destination. Write a bash command line that will verify that no more than two (2) network devices are used to pass messages from the syccuxas01.pcc.edu server to the www.pcc.edu server. 3. Write a bash command line...
Why is java programming better than bash scripting. Why should programmers write in java code ?...
Why is java programming better than bash scripting. Why should programmers write in java code ? Come up with situations where java is a better option.
1. Write a bash command that will display the value of all environment variables defined in...
1. Write a bash command that will display the value of all environment variables defined in your shell process, sorted in alphabetical order, and numbered. Here is a sample of the type of output your command should produce: 1 } 2 ALSA_CONFIG_PATH=/etc/alsa-pulse.conf 3 AUDIODRIVER=pulseaudio 4 BASH_FUNC_mc%%=() { . /usr/share/mc/mc-wrapper.sh 5 COLORTERM=1 2. Write a bash command that will display the value (and only the value) of the JAVA_ROOT environment variable. Here is a sample of the type of output your...
please explain the following command sequences a) who | grep "Seneca" | sort | uniq >>who<<...
please explain the following command sequences a) who | grep "Seneca" | sort | uniq >>who<< b)sort <names > names c)sort ~/files/phone 1> /dev/null2>phone2 d)ls/root/&> files.log e)ls/etc/>files.log2>&1
Explain the difference between central command planning and indicative planning. An example of a country that...
Explain the difference between central command planning and indicative planning. An example of a country that uses indicative planning is France; explain how indicative planning has been applied in France and its relative success. Given the complexity of the interdependencies in modern industrial technology, explain how indicative planning might complement a more successful industrial development for a country. What is the weakness of indicative planning in this regard? Carefully explain.
Explain the difference between central command planning and indicative planning. An example of a country that...
Explain the difference between central command planning and indicative planning. An example of a country that uses indicative planning is France; explain how indicative planning has been applied in France and its relative success. Given the complexity of the interdependencies in modern industrial technology, explain how indicative planning might complement a more successful industrial development for a country. What is the weakness of indicative planning in this regard? Carefully explain.
Ubuntu Linux HW5: text processing; scripting 1. Write a Linux command to rewrite the /var/passwd file...
Ubuntu Linux HW5: text processing; scripting 1. Write a Linux command to rewrite the /var/passwd file to have a tab for each delimiter ':'. Hint: use tr 2. Write a Linux command to extract the user names and sort them. Hint: use cut 3. Write a for loop to to display a time table, e.g., 17 x 1 = 17; 17 x 2 = 34; etc., as follows: 17 x 1 = 17 17 x 2 = 34 17 x...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT