Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
echo, cat, seq, wc, head, tail, less, more ‣ echo writes command line arguments to stdout UNIX> echo HELLO THERE HELLO THERE ‣ Use double quotes for complex strings UNIX> echo “> < | 2> >> 2>> ! * #” > < | 2> >> 2>> ! * # ‣ cat prints stdin to stdout UNIX> cat I am typing this message <ENTER> I am typing this message <CTRL-C> UNIX> ‣ cat concatenates file(s) and prints to stdout ‣ File(s) specified as command line arguments UNIX> echo “line 1” > input1.txt UNIX> echo “line 2” > input2.txt UNIX> cat input1.txt input2.txt line 1 line 2 ‣ seq outputs a sequence of numbers to stdout ‣ Single command line argument: seq to – starts at 1 – increments by +1 UNIX> seq 3 1 2 3 ‣ two command line arguments: seq from to ‣ default increment is +1 UNIX> seq -1 1 -1 0 1 UNIX> seq 2.5 3.5 2.5 3.5 ‣ three command line arguments: seq from incr to UNIX> seq 2 -1 -2 2 1 0 -1 -2 ‣ three command line arguments: seq from incr to UNIX> seq 0 0.3 1 0.0 0.3 0.6 0.9 ‣ wc displays the number of lines, words, and characters in file(s) ‣ wc output: num_lines num_words num_chars ‣ wc takes command line argument(s) or stdin [file] UNIX> echo HELLO THERE > input1.txt UNIX> echo THIS IS ANOTHER FILE > input2.txt UNIX> wc input1.txt input2.txt 1 2 12 input.txt 1 4 21 input2.txt 2 6 33 total ‣ -l for lines only (lower case L) ‣ -w for words only ‣ -c for characters only UNIX> echo HELLO THERE | wc –c 12 UNIX> echo HELLO THERE | wc –c –w 2 12 UNIX> echo HELLO THERE | wc 1 2 12 UNIX> seq -74.5 0.01 64.47 | wc 13898 13898 88839 ‣ head prints the first line(s) of a file ‣ head accepts a command line argument or stdin ‣ by default, head prints the first 10 lines UNIX> seq 100 | head 1 … 10 ‣ –n command line option specifies number of lines UNIX> seq 100 > file.txt UNIX> head –n 2 file.txt 1 2 UNIX> seq 100 | head –n 1 1 ‣ tail prints the last line(s) of a file ‣ tail accepts a command line argument or stdin ‣ by default, tail prints the last 10 lines UNIX> seq 100 | tail 91 … 100 ‣ –n command line option specifies number of lines UNIX> seq 100 > file.txt UNIX> tail –n 2 file.txt 99 100 UNIX> seq 100 | tail –n 1 100 ‣ Use head and tail to print specific lines: UNIX> seq 100 | head -n 50 | tail -n 5 46 47 48 49 50 ‣ less displays a file in read-only mode ‣ Accepts command line argument(s) or stdin ‣ Great way to (quickly) view file contents ‣ Navigate with up and down arrows ‣ ‘q’ to quit UNIX> less file.txt UNIX> seq 1000 | less ‣ more displays a file in read-only mode ‣ Accepts command line argument(s) or stdin ‣ Great way to (quickly) view file contents ‣ Page down with spacebar (no arrows) ‣ ‘q’ to quit UNIX> more file.txt UNIX> seq 1000 | more ‣ A joke amongst Linux users… ‣ Practice using output commands http://eecs.mines.edu/Courses/csci274/ Assignments/9_output.html