Write a shell program called find to locate an existing record in users.ref and
ID: 643860 • Letter: W
Question
Write a shell program called find to locate an existing record in users.ref and display the student's username and full name on the screen. The search should not be case sensitive. This shell program should allow the user to specify either a student's username or their full name. Save the find shell program in the lab7 directory.
Did you encounter any problems in the previous step? If so, what were they and how did you resolve them? Include a note describing the problems and solutions in a file calledlab7.notes.
Write a shell program called remove which deletes a student's entry from your users.ref file. Similar to find, the user should be able to specify the student to be removed by their username or their full name. Save the remove shell program in lab7. (hint: grep has an option "-v". Go check it out!)
Write a shell program called add to add a new username and full student's name to your users.ref file. Your program should be used in the following manner (hint: echo hello >> file):
Explanation / Answer
shell script
$ find "lily.brown"
grep -h -i $1 < users.ref
this command grep will search for the pattern (that has been passed as command line argument to the script in $1) in the text file users.ref
the -h switch will display only the line of text and not other details. the -i will make the search case insensitive.
the word being searched can be the username or the full name , which ever is being passed that will be searched and located
remove -
the sed command is used to remove text from the txt file
sed $1 'users.ref'
the value contained in the first command line argument is removed from the file users.ref
To add a new user name which is passed as command line argument - two arguments holding the userrname and the full students name is passed
program add $1 $2
echo "$1" >> 'users.ref'
echo "$2" >> 'users.ref'
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.