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

text processing format
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Command-line

Linux

Text processing Format

IASP 321 IASP 221

Text File

  • Dr. John Yoon
slide-2
SLIDE 2

Text Processing

  • Commands
  • cat
  • sort
  • uniq
  • cut
  • paste
  • join
  • comm
  • diff
  • patch
  • tr

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

slide-3
SLIDE 3

Text Processing

  • Commands
  • cat
  • sort
  • uniq
  • cut
  • paste
  • join
  • comm
  • diff
  • patch
  • tr

sort set1.txt > set1s.txt sort set2.txt > set2s.txt comm set1s.txt set2s.txt

slide-4
SLIDE 4

Extend to Linux Scripting

  • For loop to write on a file
  • For loop to compute
  • Paste the files

for ((i=1;i<=10;i++)); do echo "You earn" $[$i*10] >> helloM2.data; done for ((i=1;i<=10;i++)); do echo "Hello Mercy" $i >> helloMercy.txt; done paste helloMercy.txt helloM2.data

Computation in [ ] Treat as a variable Run this on a shell command prompt, e.g., jyoon@UbuntuServer:~$

slide-5
SLIDE 5

Maybe Encoding?

  • Scramble
  • How to restore?

echo "Mercy Cybersecurity" | tr a-zA-Z n-za-mN-ZA-M echo "Mercy CyberSecurity" | tr a-zA-Z n-za-mA-Z

slide-6
SLIDE 6

Extend to Linux Scripting

  • Create two files starting with the common

field

  • Join the files based on the common field

join numMercy.data numMondy.data 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

Run this on a shell command prompt, e.g., jyoon@UbuntuServer:~$

slide-7
SLIDE 7

Printing

  • Commands
  • pr
  • lpr
  • lp
  • a2ps
  • lpstat
  • lpq
  • lprm
  • cancel

The package should be installed and link real printer devices