Can you figure out what this script does?
- This script searches for all files or directories that contain a specified keyword (above: “cms”)
What do you think chmod command does?
- The chmod command changes the permissions for the file: for example, the command +x changed the permission so that testscript.tcsh became an executable
Now, as an exercise, try using emacs to write a simple script based on testscript.tcsh called homesearch.tcsh which takes one input, <input>.
homesearch.tcsh should search your home directory and its subdirectories for any files which contain <input> somewhere in their name. Finally, homesearch.tcsh should log the results of the search to a file called homesearch_<input>.txt. (Don't forget to 'chmod +x' your new script!)
Try:
touch testfile
./homesearch.tcsh testfile
cat homesearch_testfile.txt
What is the output of this script?
- The script, after searching for all files/directories that contain the keyword “testfile”, displays the results of that search in the terminal.
In Linux, what is piping (done with the symbol | )? Write a short description
- Piping is used to run two or more commands in quick succession – the | symbol will “pipe” the output of the first command to be used as the input of the next command
Copy paste the following text to create test.txt file in your directory. Write a script that uses this and/or other commands to :
1. replace every "was" with "is"