CAT Command
-- show line numbers of the lines in a file
cat -n <file_name>
creating a file
cat > testing
enter content
quite
-- testing file is created
Create a copy of the file
cat StudentData > StudentData
Merging two files and creating a new file.
cat <file1> <file2> > totaldata.txt
append a content of a file to a existing file
cat <file_name> >> <file_name>
showing a file in reverse order -- cat command now becomes tac
tac <file_name>
list files
ls -ltr
list all files in human readable format
ls -ltrh
display files ignoring blank lines
cat -n -b <file_name>
-b // skips blank lines
head command to show only first 10 lines from a file
head <file_name>
first 10 line
display first 20 lines from a file
head -n 20 <file_name>
or
head -20 <file_name>
display 200 bytes of data from this file
head -c <file_name>
skip last 28 lines
head -n -28 lines // the hypen skips the last 28 lines
display 10 lines from the bottom of the file
tail <file_name>
display 20 lines from a file
tail -n -20 <file_name>
display 2000 bytes from the bottom of the file
tail -c 2000 <file_name>
more command to check page by page
more <file_name> press space to move to the next page
q to checkout of the file
want to display content of the file and also how to use how to use different controls while reading the page
more -d <file_name> // d flag also instructs you with what control buttons to use
more command cannot backwards and can move only towards forward direction.
less command can move forward direction and backward direction
less <file_name>
d - for down one page
b - back
q -- to come back
grep command
grep -i 2010 <file_name> > file_name.txt
head -n 12 <file_name> > file_name.txt
-- Pick 15 lines from the bottom of the file and place it in file named <hotel-search>
tail -n 15 <file_name> >> <filename
Pipe symbol --- pipe symbol can be used to make a link between them
fetching data from the middle of the file 15 - 28
head -n 23 <file_name> | tail -n 8
the first 23 lines of the file is directed to the another command to fetch last 8 lines from the output given to it using pipe symbol
head -n 23 <file_name> | tail -n 8 | grep 2010
process commands ps -ef -- I want to display only those process that have keyword 'monitor' in them
ps -ef | grep monitor
ls -l | grep -i Folder // Ignore Case
-i -- Ignore case
Comments
Post a Comment