CISC 5500 Data Analytics Tools and Scripting find and grep Computer and Information Science Fordham University
Table of contents 1. find 2. grep 1
review myfunc () { # do something here } if [ some condition ] then # do something here fi while [ some condition ] do # do something here done for item in item1 item2 item3 do # do something here done 2
find
find Search for files in a directory hierarchy. A simple example: find all the files called something dot jpg under the current directory. find . -name "*.jpg" 3
grep
grep Print lines matching a pattern. A simple example: find all the lines that contains ’test’ in all the files in the current directory grep test * 4
xargs Build and execute command lines from standard input. A simple example: compare cat and echo , but the ’argument’ is unknown when the command is entered xagrs echo xargs cat Real application: downstream of the pipe 5
scp Copy between different computers. A simple example: get a file from my account on the storm server scp ji@storm.cis.fordham.edu:~/test2.txt . 6
Summary • find • grep 2020.9.17 7
Questions? 7
regular expression Regular expression is a formal language to specify patterns. • line beginning and ending ^ $ • dot (matching all) and character set [] • quantification (repetition operators) • ? • * • +
Recommend
More recommend