Menu

Dipesh Majumdar

Blog and Paintings

Some useful Linux Commands - 3

October 22, 2015
  1. Do you really want to know if something is running on a port?

    Use this - 

    netstat -an | grep 80 | grep LISTEN
    tcp        0      0 :::80                       :::*                        LISTEN

  2. How to append a line to a text file?
    This is very easy:
    echo -e "Some Line which needs to be appended to a file\n" >> this_is_file.txt
  3. How to append aline to a text file? That means how to add a line in beggining of a file?
    (echo "Some Line to be added in beginning of file"; cat this_is_file.txt) > this_is_file_Temp.txt
    mv this_is_file_Temp.txt this_is_file.txt
  4. How to concatenate 3 files (file1,file2 and file3) - one after another - in one single file?
    There should be many ways - but this should work -
    ( cat file1.txt;cat file2.txt; cat file3.txt) >one_single_file.txt
  5. With xargs escape double quotes doesn't work. How to make it work? Hint:  Try using -0 with xargs
    app_user@hostname:~$ echo -e "{xyz:\"pqr\",y:"
    {xyz:"pqr",y:
    app_user@hostname:~$ echo -e "{xyz:\"pqr\",y:" |xargs echo
    {xyz:pqr,y:
    app_user@hostname:~$ echo -e "{xyz:\"pqr\",y:" |xargs -0 echo
    {xyz:"pqr",y:

Go Back

Comment