How do i create a new file using the cat command?



  • One of the wonderful things about Linux and Unix is there are a number of ways of doing a task to achieve the same result.

    If you need to do a quick simple script without going into editors, you can use the cat command.

    $ cat > mytemp.sh
    last | grep reboot
    ^D
    $ chmod +x mytemp.sh
    $ ./mytemp.sh
    

    If you use the same filename again using the above method, the content will be overwritten, but it's handy for running quick one-liners, that is usually longer than the example shown here.


Log in to reply
 

© Lightnetics 2024