faster bash operations on files with File Descriptors.

2011-06-11 2 min read bash Learning Linux
I was writing a bash script that would do some operations and read and write to file. Seems that that was pretty simple with 1 2 3 4 5 <td> <div class="text codecolorer"> while read line<br /> <br /> do<br /> <br /> done<file </div> </td> </tr> and then use redirection operations like “>” and “»” to write to file. Done with the script pretty fast. So far so good, when I went for real life tests, no one was interested in using it, why? Continue reading

Unix shell script for removing duplicate files

2011-05-16 1 min read bash Linux
The following shell script finds duplicate (2 or more identical) files and outputs a new shell script containing commented-out rm statements for deleting them (copy-paste from here): ::: updated on 02 May 20121, seems like wordpress did not like it so well so reformatting the code ::::::: #!/bin/bash - #=============================================================================== # # FILE: a.sh # # USAGE: ./a.sh # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Amit Agarwal (aka), amit. Continue reading

cd across parallel directories

2011-03-14 1 min read bash Linux
Image via Wikipedia Here is a simple and fast way to cd across parallel directory. 1 <td> <div class="text codecolorer"> cd ${PWD/test/actual} </div> </td> </tr> Related articles Linux command line tips: wget (ghacks.net) Article Directory Submissions (tjantunen.com) Article Directory Submissions (cash-bandit.com) Create a repository from your fedora DVD (annupandey.wordpress.com)

Ranking of the most frequently used commands

2011-01-31 2 min read Linux Uncategorized
Lets take a quick look at how to get the most frequently used commands on you shell. So what we need to do is this: 1 <td> <div class="text codecolorer"> history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr </div> </td> </tr> So, how did we arrive at this and will this always work? No it might not always work. Continue reading

shopt causes bash completion to stop working.

2011-01-25 1 min read bash
Couple of days, I added some scripts to my bash startup and suddenly realized that bash completions stopped working. This is tricky situation in bash to figure out what went wrong. So, I set my foot down to make sure that I find out the culprit. Thus I started with method of elimination. So, I started with nothing in .bashrc and kept adding my stuff in batches, until the said feature was broken. Continue reading

Shell Scripting

2011-01-05 1 min read bash Learning Linux
Here are some links for bash programming that you may find useful. http://tips-linux.net/en/content/pro-bash-programming http://tips-linux.net/en/content/expert-shell-scripting http://tips-linux.net/en/content/beginning-linux-command-line http://tips-linux.net/en/content/bash-pocket-reference http://tips-linux.net/en/content/linux-command-line-and-shell-scripting-bible Related articles Linux – Learning the Shell (edugeek.net) 10 Useful Tools, Websites And Tricks to Help You Master Linux Command (maketecheasier.com) lf-submit.sh – Bash mplayer Last.fm scrobbler (yjl.im) Linux command line tricks you need to know: IO redirection and piping (interstellr.com) imabonehead: Houcem HACHICHA’s Blog: My top ten shell/bash tricks! (houcemhachicha.blogspot.com)
Older posts Newer posts