Useful Bash Commands

Have a list of hostnames or IP addresses in hosts.txt and need the FQDN instead? Use command:

Now you have a txt file with a list of FQDNs. You want to ping all those hosts to check the connectivity? Use command:

Sometimes I have the need to login to a list of servers to check different settings and so forth. In this example I need to check where debug is sending logs.

Looping and skipping by 2

Taking input as variable

Use of math and numbers

Comparing numbers

Use this one-liner often to pull IP address from http logs.

Something to use to mask certain text in files or filenames themselves.

Now delete the original file and when ready to read it again, just run same function… but reverse the files.

Tags: , ,

One comment to Useful Bash Commands

  • thepuregeek

    for i in $(seq 1 25); do echo $i; done


Leave a Reply