text processing format
play

Text processing Format Text File IASP 321 IASP 221 Dr. John Yoon - PowerPoint PPT Presentation

Command-line Linux Text processing Format Text File IASP 321 IASP 221 Dr. John Yoon Text Processing Commands cat cat > foo.txt sort sort foo.txt sort foo.txt | uniq -c uniq du s /usr/share/* | sort nr | head


  1. Command-line Linux Text processing Format Text File IASP 321 IASP 221 Dr. John Yoon

  2. Text Processing  Commands • cat cat > foo.txt • sort sort foo.txt sort foo.txt | uniq -c • uniq du –s /usr/share/* | sort –nr | head • cut ls -l /usr/bin | sort -nr -k 5 • paste sort --key=1,4 --key=2n linuxDistriShort.txt • join sort --key=2,3 --key=2n linuxDistriShort.txt • comm cut -f 7 LinuxDistributors.txt | cut -c 1-4 • diff diff a.txt b.txt • patch • tr

  3. Text Processing  Commands • cat sort set1.txt > set1s.txt sort set2.txt > set2s.txt • sort comm set1s.txt set2s.txt • uniq • cut • paste • join • comm • diff • patch • tr

  4. Extend to Linux Scripting Run this on a shell command prompt, e.g., jyoon@UbuntuServer:~$  For loop to write on a file for ((i=1;i<=10;i++)); do echo "Hello Mercy" $i >> helloMercy.txt; done  For loop to compute for ((i=1;i<=10;i++)); do echo "You earn" $[$i*10] >> helloM2.data; done  Paste the files Computation in [ ] paste helloMercy.txt helloM2.data Treat as a variable

  5. Maybe Encoding?  Scramble echo "Mercy Cybersecurity" | tr a-zA-Z n-za-mN-ZA-M echo "Mercy CyberSecurity" | tr a-zA-Z n-za-mA-Z  How to restore?

  6. Extend to Linux Scripting Run this on a shell command prompt, e.g., jyoon@UbuntuServer:~$  Create two files starting with the common field for ((i=1;i<=10;i++)); do echo $i "of Mercy" >> numMercy.data; done for ((i=1;i<=10;i++)); do echo $i "has " $[$i*100] >> numMondy.data; done  Join the files based on the common field join numMercy.data numMondy.data

  7. Printing  Commands • pr The package should be installed and link real printer devices • lpr • lp • a2ps • lpstat • lpq • lprm • cancel

Recommend


More recommend