CSE 391
Shell commands
More Redirection
Slides created by Josh Ervin and Hunter Schafer. �Based off slides made by Marty Stepp, Jessica Miller, Ruth Anderson, Brett Wortzman, and Zorah Fung
AGENDA
ROADMAP
PIPES
command1 | command2
command1 > filename
command2 < filename
rm filename
COMBINING COMMANDS
command1 ; command2
command1 && command2
command1 || command2
What would happen after running the following command: ls *.java | javac
Solution: This won’t work because javac does not read from stdin! Piping makes the stdout of the last program become stdin of the next.
XARGS
FIND
COMMAND SUBSTITUTION
$(command)
What is the command to remove all files listed in the file toRemove.txt?
toRemove.txt
CompilerErrors.java
beans.txt
xargs rm < toRemove.txt
STDERR REDIRECTION
TEE
Suppose we want to run the Java program Mystery. What would be the command to output both standard error and standard output to mystery_out.txt and print both to the console?
java Mystery.java 2>&1 | tee mystery.txt
CUT
cut -d<DELIMITER> -f<FIELD>
LOGS
$ tail -f /cse/web/courses/logs/common_log | grep “391”