Empty a file

2010-12-26 1 min read Learning Linux
<dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;"> Image via <a href="http://commons.wikipedia.org/wiki/File:Calculator.NET_Screenshot.png">Wikipedia</a> </dd> </dl> This one is for those who know the “touch” command. Hope all of us do not follow a command just because it is on one of the popular site without trying to understand the command and the output. Empty a file 1 <td> <div class="text codecolorer"> touch file </div> </td> </tr> * View this command to comment, vote or add to favourites * View all commands by noisy Continue reading

Bash Script Beautifier

2010-12-23 1 min read bash Learning Linux
<dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;"> Image via <a href="http://en.wikipedia.org/wiki/File:Bash-org.png">Wikipedia</a> </dd> </dl> Today I was working on a bash script written by someone else. And the script was maintained since long and had actually become quite big and there was no indentation followed. So, you can understand how difficult it was to understand the script. So, I set my foot forth to first find a beautifier for the bash script before I fixed it and my search ended here. Continue reading

Make any command read line enabled (on *nix)

2010-11-25 1 min read bash Fedora Linux
Make any command read line enabled (on *nix) 1 <td> <div class="text codecolorer"> rlwrap sqlite3 database.db </div> </td> </tr> Enable readline even if the command line application is not using it. * View this command to comment, vote or add to favourites * View all commands by pykler commandlinefu.com by David Winterbottom (codeinthehole.com) URL: http://feedproxy.google.com/~r/Command-line-fu/~3/mKEgYoyHCMA/make-any-command-read-line-enabled-on-nix Related articles Use the last command’s output as input to a command without piping and bind to it to a key sequence in bash. Continue reading

Broadcast your shell thru port 5000

2010-11-20 1 min read bash Fedora Linux
Broadcast your shell thru port 5000 1 <td> <div class="text codecolorer"> mkfifo /tmp/fifo;(nc -q0 -l 5000 < /tmp/fifo &);script -f /tmp/fifo </div> </td> </tr> run 1 <td> <div class="text codecolorer"> nc yourip 5000 </div> </td> </tr> elsewhere will produce an exact same mirror of your shell. This is handy when you want to show someone else some amazing stuff in your shell without giving them control over it. * View this command to comment, vote or add to favourites * View all commands by clvv Continue reading

function for copy files with progress bar (using pv – pipe viewer)

2010-11-11 1 min read bash Linux
function for copy files with progress bar (using pv – pipe viewer) 1 <td> <div class="text codecolorer"> &nbsp;cp_p() { if [ `echo "$2" | grep ".*/$"` ]; then pv "$1" > "$2""$1"; else pv "$1" > "$2"/"$1"; fi; } </div> </td> </tr> dont have to type new file name (it copy file under same name) and dont have to use ‘/’ in the end of destination folder (but you can if u want, its idiot proof) Continue reading

Print all environment variables, including hidden ones

2010-11-09 2 min read bash Fedora Linux
Print all environment variables, including hidden ones 1 <td> <div class="text codecolorer"> for _a in {A..Z} {a..z};do _z=${!${_a}*};for _i in `eval echo "${_z}"`;do echo -e "$_i: ${!_i}";done;done|cat -Tsv </div> </td> </tr> This uses some tricks I found while reading the bash man page to enumerate and display all the current environment variables, including those not listed by the ‘env‘ command which according to the bash docs are more for internal use by BASH. Continue reading

bash script to run a command and take screenshot in every loop.

2010-09-24 2 min read bash Fedora Learning Linux
Couple of days back, I had posted a command to display a stop timer with bash and echo. There I had also put the following gif file: <img class="size-medium wp-image-2555" title="bash screenshot for the script output" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/09/temp-300x170.gif" alt="bash screenshot for the script output" width="300" height="170" /> Here the tricky part was to capture the jpg&#8217;s to create the gif file. Preparation: Rename the terminal to aka – amit-capture Execute the command once with the import command and check the output and jpg&#8217;s Continue reading
Older posts Newer posts