Login using Social Account
     Continue with GoogleLogin using your credentials
A shell script is a file which contains the commands separated by a newline.
Let's create a script to do the sorting of the data:
Create a file using nano text editor:
nano wordcountscript.sh
The first line of a script should have #!
followed by the name of the program to execute the script with. Since we are creating a shell script, we want it to be executed using bash
. So, the first line of the program should be:
#!/bin/bash
Add the command in the editor:
tr 'A-Z' 'a-z'| sed -E 's/[ \t]+/\n/g'|sed 's/[^0-9a-z]//g' | sort|uniq -c|sort -nr -S 50M
Save the file by pressing Ctrl+x
and y
Now, make this file executable:
chmod +x wordcountscript.sh
Check if it is running:
cat /cxldata/big.txt | ./wordcountscript.sh | more
Please recall ./
means current directory and | more
will show the result pagewise instead of causing too much scrolling.
Also, note that whatever is the input to the script is also passed to the programs executed in the script.
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...