bash โ€“ echo command with option to display the output on the same line.

2010-09-21 2 min read bash Fedora Learning Linux
Here is a nice little trick to display the output in the same line : 1 <td> <div class="bash codecolorer"> &nbsp;<span class="kw3">echo</span> <span class="re5">-ne</span> <span class="st0">"output\<span class="es1">\r</span>"</span> </div> </td> </tr> The trick here is simple, first we disable the <a class="zem_slink" title="Newline" rel="wikipedia" href="http://en.wikipedia.org/wiki/Newline">newline printed by <a class="zem_slink" title="Echo (command)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Echo_%28command%29">echo command with the &#8221;-n&#8221; option and then we enable the interpretation of the <a class="zem_slink" title="Backslash" rel="wikipedia" href="http://en. Continue reading

Remove some path from the PATH variable temporarily.

2010-09-04 2 min read bash Linux
How many times has it happened to you that you are working on some linux platform (like Fedora/Ubuntu/CentOS etc) and suddenly you see that you need to remove some path from the PATH variable so that a script is executed from some other path. It really difficult to do this if the path is too long and if you end up doing this couple of times. If that is the case, then the below script is for you ๐Ÿ™‚ Continue reading

Use the last command\โ€™s output as input to a command without piping and bind to it to a key sequence in bash.

2010-09-01 1 min read Fedora Linux Uncategorized
Use the last command&#8217;s output as input to a command without piping and bind to it to a key sequence in <a class="zem_slink" title="Bash (Unix shell)" rel="homepage" href="http://tiswww.case.edu/php/chet/bash/bashtop.html">bash. 1 <td> <div class="bash codecolorer"> &nbsp;<span class="kw3">bind</span> <span class="co3">\'</span><span class="st0">"\\C-h"</span>: <span class="st0">"\\<span class="es5">`fc\\ \\-s\\`</span>"</span><span class="co3">\'</span> </div> </td> </tr> My comment : fc is the fix command of the bash builtin. This is similar to using `!!` or In bash 4.1 it seems you can bind directly to a shell command, but I&#8217;m Continue reading

tee to a file descriptor

2010-08-13 1 min read bash Linux
tee to a file descriptor 1 $ tee >(cat &#8211; >&2) the tee command does fine with file names, but not so much with file descriptors, such as &2. This uses process redirection to tee to the specified descriptor. In the sample output, it’s being used to tee to stderr, which is connected with the terminal, and to wc -l, which is also outputting to the terminal. The result is the output of bash โ€“version followed by the linecount Continue reading

Magic space on the current command line

2010-06-25 1 min read bash Fedora Linux
# For how to set up magic space for Bash see: # โ€“ http://www.ukuug.org/events/linux2003/papers/bash_tips/#slide15 # โ€“ http://codesnippets.joyent.com/posts/show/1690 man bash 2>/dev/null | less -p &#8217;magic-space&#8217; man bash 2>/dev/null | less -p &#8217;Event Designators&#8217; man bash 2>/dev/null | less -p &#8217;\!#&#8217; # &#8221;The entire <a class="zem_slink" title="Command-line interface" rel="wikipedia" href="http://en.wikipedia.org/wiki/Command-line_interface">command line typed so far.&#8221; <a href="http://snippets.dzone.com/posts/show/10265">Read more :<h6 class="zemanta-related-title" style="font-size: 1em;">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://www.makeuseof.com/tag/trigger-wake-lan-mac-address/">How To Trigger Wake On LAN Using The MAC Address (makeuseof. Continue reading

colors in bash -- script to display all the possible colors.

2010-06-06 3 min read bash Fedora Linux
If you wanted to have colors in the bash output (including the colors in PS1-4), don&#8217;t you keep wondering how the color code would look on the terminal. So, I wrote this small script to show the complete color codes. This is how the output would look: And here is the script: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Continue reading
Older posts Newer posts