0% found this document useful (0 votes)
54 views1 page

Chapter4 Creating Viewing and Editing Text Files

This document discusses Linux commands for redirecting standard input/output, constructing pipelines, and editing files. It provides examples of using > and >> to redirect output to files, | to pipe output between commands, and commands like date, ls, find, less, head, tail, tee, vim, gedit and nano.

Uploaded by

Muhammad Hatem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views1 page

Chapter4 Creating Viewing and Editing Text Files

This document discusses Linux commands for redirecting standard input/output, constructing pipelines, and editing files. It provides examples of using > and >> to redirect output to files, | to pipe output between commands, and commands like date, ls, find, less, head, tail, tee, vim, gedit and nano.

Uploaded by

Muhammad Hatem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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