Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

INPUT OUTPUT REDIRECTION

whoami = Prints the username of current user


whoami>/home/shailesh/Desktop/who = Writes the username of current user in
/home/shailesh/Desktop/who file
cd /home/$(whoami) = Changes the current directory to current user (~)
from root(/)
id = Prints id of current user in details
id>>/home/shailesh/Desktop/who = appends the previous content of file with id
(current)
ps -ef = Lists the running programs from all users
ps -ef | grep "firefox" = Lists details of firefox application
kill 9828 = Kills the process with process id 9828 .../usr/lib64
(Eg. firefox here is 9828)
ps -ef | awk -F" " '{print $2}' = Prints only second column of result given by
ps -ef
ps -ef | awk -F" " '{print $2}' | rev = Prints each element in reverse order
(eg. 901 is printed as 109)
ps -ef | awk -F" " '{print $2}' | rev > file01 = writes the content given by above
command in file01
ps -ef | awk -F" " '{print $2}' | rev > file01 && cat file01 = Writes and
displays file01 at once
ps -ef | awk -F" " '{print $2}' | rev > file01 && cat file01 | rev >> file01 && cat
fileo1 = writes in reverse, displays, appends, again reverses, again writes
and again displays

ERROR REDIRECTION

ll /home/shailesh/Desktop/asdjkhajkds = no file or directory found


ll /home/shailesh/Desktop/asdjkhajkds 2>/home/shailesh/Desktop/err = No error
message is seen; instead it is written in err file (2> command does this)

You might also like