How to create a file with cat command

How to create a file with cat command

Cat command has many use , in my earlier post I wrote about how to see line no. in file with cat command

In this example I will guide how simply you can also create a file and write content in it.

Steps to follow

In this first you hit the command cat > file-name .
After this cursor will move to next line itself. Now you can start writing.
For saving the file press “CTRL with D” from your keyboard.

cat

And to append more content in file

cat >> file-name

Note: What happen if you hit CTRL+z key while writing file using cat command.

ctrl+z is basically use for background process, to check background process run command jobs and to take back the process in foreground use fg %jobno eg. if you do cat > filename and after writing if you press ctrl+z the process will go background. When we hit the command jobs it will show jobs no. respective of process running.
To make foreground now run fg command eg fg %1 here %1 is job no. 1 . But after this the old content get clear now you can write new content again in same process.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.