Chapter4 Creating Viewing and Editing Text Files

You might also like

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

Standard input, standard output, and standard error:

[root@master ~]# date > /tmp/saved-timestamp


[root@master ~]# tail -n 100 /etc/passwd > /tmp/last-passwords.tmp
[root@master ~]# cat file1 file2 file3 file4 > /tmp/all-four-in-one
[root@master ~]# ls -a > /tmp/my-file-names
===============================================
Append output to an existing file:
[root@master ~]# echo "new line of information" >> /tmp/many-lines-of-
information
[root@master ~]# find /etc -name passwd 2> /tmp/errors
[root@master ~]# find /etc -name passwd > /tmp/output 2> /tmp/errors
[root@master ~]# find /etc -name passwd > /tmp/output 2> /dev/null
[root@master ~]# find /etc -name passwd &> /tmp/save-both
[root@master ~]# find /etc -name passwd >> /tmp/save-both 2>&1
===============================================
Constructing pipe lines:
[root@master ~]# ls -l /usr/bin | less
[root@master ~]# ls | wc -l > /tmp/how-many-files
[root@master ~]# ls -t | head -n 10 > /tmp/ten-last-changed-files
[root@master ~]# ls -l | tee /tmp/saved-output
[root@master ~]# ls -l | tee /dev/pts/0 | mail -s subject root
===============================================
Editing files with Vim:
[root@master ~]# vim file1
===============================================
Editing files with gedit:
Applications > Accessories > gedit
[root@master ~]# gedit file1
===============================================
Editing files with nano:
[root@master ~]# nano file1
===============================================

You might also like