1-2 Use Input-output Redirection (>,>>,|,2,etc...) Flashcards
Redirect output into a file,
Not include error messages
cat FileName1 > FileName2
Redirect error messages into a file,
Not include output
cat FileName1 2> FileName2
Redirect output AND error messages into a file
cat FileName1 &> FileName2
cat FileName1 > FileName2
Redirect output into a file,
Not include error messages
cat FileName1 2> FileName2
Redirect error messages into a file,
Not include output
cat FileName1 &> FileName2
cat FileName1 > FileName2 2>&1
Redirect output AND error messages into a file
cat NoFileName FileName 2>&1 | grep “No such file”
Redirect error messages into stdout,
Which allows error (AND output) both to be piped
mysql TableName < FileName
Input redirection into commands that accept input
cat largefilename > /dev/null
cat NoFileName LargeFileName &> /dev/null
Redirect output into deletion
Redirect output AND error into deletion
head FileName
Display first ten lines of file
tail FileName
Display last ten lines of file
head -n 5 FileName
Display first 5 lines of file
tail -n 5 FileName
Display last five lines of file
less FileName
ENTER key to scroll down by line
SPACE key to scroll down by page
b key to scroll back by page
Display only one page(screen) at a time of file
Access is faster because whole file is NOT accessed(processed)
more FileName
ENTER key to scroll down by line
SPACE key to scroll down by page
b key to scroll back by page
Display only one page(screen) at a time of file
Access is NOT faster because whole file is accessed(processed)