Saturday, October 29, 2011

Usage of cat command

cat command functionality:
1. create
2. view
3. join files

cat is short for catenate (to join things together, end-to-end)
- Create file
cat > file1
enter text
more text
# press Enter, CTRL-d to exit

- View file(s)
cat -n filename # will number all lines
cat -b filename # will number all non-blank lines

cat -t filename # all tabs to be shown as ^I
cat -s filename # remove extra blank lines. 1 blank line is allowed.
cat -A filename # combine -t & -s options together

- Join Files
cat test1 test2 # join both files and show output in stdout
cat test1 test2 > test # Join both files and add to stdout

No comments:

Post a Comment