Tag: example

  • Analyze history for most used commands

    With history and a little bit of awk we make the magic. List commands in history by usage. Two examples above, the simple one and the advanced where the arguments to the commands are shown.


     

    history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head

    #Advanced version
    history | awk '{a[$2 " " $3 " " $4 " " $5]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head -n+25

  • How to generate a tar gz file from a file list

    Easy example of tar use. We provide a list of files to archive them in one tar file.
    tar zcvf myFile.tar.gz file1.txt file2.txt file3.txt file4.txt