Sunday, 17 April 2016

How to create and display file contents using cat command ?


Create file
# cat > create-linux-file.txt
contents here ...

Display file
# cat create-linux-file.txt

Appends text to file
# cat >> create-linux-file.txt
this is the line appends to create-linux-file.txt
this is an example on using redirection to appends text


Switches
-n, --number    number all output lines
-b, --number-nonblank    number non-blank output lines
-E, --show-ends      display $ at end of each line
-s, --squeeze-blank       never more than one single blank line
-T, --show-tabs     display TAB characters as ^I
-u      (ignored)
-v, --show-nonprinting    use ^ and M- notation, except for LFD and TAB
     --help    display this help and exit
     --version     output version information and exit
-A, --show-all      equivalent to -vET
-t     equivalent to -vT
-e    equivalent to -vE

Example
# cat -n create-linux-file.txt
Contents here...

No comments:

Post a Comment

Note: only a member of this blog may post a comment.