symlinks -delete all invalid soft links in Linux/Fedora

2012-06-12 1 min read Bash Fedora Linux

First of all, install symlinks if it is not installed :

sudo yum install symlinks

and here is the description:

Description : The symlinks utility performs maintenance on symbolic links.
Symlinks checks for symlink problems, including dangling symlinks
which point to nonexistent files.  Symlinks can also automatically
convert absolute symlinks to relative symlinks.
Install the symlinks package if you need a program for maintaining
symlinks on your system.

and the help for the same:

Continue reading

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

  <td>
    <div class="text codecolorer">
      while read line<br /> <br /> do<br /> <br /> done<file
    </div>
  </td>
</tr>
1
2
3
4
5

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? Simple, it was simply taking too long. The file was reading about 10K lines and writing about 50 lines and was taking about more than 10 minutes.

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

coproc help - a new feature in bash

2010-05-10 0 min read Bash Fedora Linux
\"Screenshot
Image via Wikipedia

In the <a class="zem_slink freebase/en/bash" title="Bash" rel="homepage" href="http://tiswww.case.edu/php/chet/bash/bashtop.html">bash version 4.0, there is a new concept called coproc. This is very useful for some of the daily tasks.

co-<a class="zem_slink freebase/guid/9202a8c04000641f800000000005a409" title="Process (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Process_%28computing%29">process starts a process in the background, optionally with a NAME, with which other processes can communicate. This can be a very <a class="zem_slink freebase/en/substitute_good" title="Substitute good" rel="wikipedia" href="http://en.wikipedia.org/wiki/Substitute_good">good substitution for <a class="zem_slink freebase/guid/9202a8c04000641f800000000048fac5" title="Pipeline (Unix)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Pipeline_%28Unix%29">pipes in lots of cases. You can learn more about coproc in the link below:

Continue reading

prepend to a file with sponge from moreutils

2010-03-16 1 min read Linux

<a href="http://bashcurescancer.com/prepend-to-a-file-with-sponge-from-moreutils.html">A few weeks I wrote about a tool, which helps you easily prepend to a file. I submitted prepend to moreutils and Joey was kind enough to point out this could be done with `sponge&#8217;.? sponge reads standard input and when done, writes it to a file:
Probably the most general …<h6 class="zemanta-related-title">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://helpdeskgeek.com/linux-tips/crontab-howto-tutorial-syntax/">Automating Tasks in Linux Using Crontab (helpdeskgeek.com) <li class="zemanta-article-ul-li"><a href="http://www.slideshare.net/progrium/sxsw-evented-web">How WebHooks Will Make Us All Programmers (slideshare.net) <li class="zemanta-article-ul-li"><a href="http://almirkaric.com/2010/01/07/debugging-python-multiprocessing/">Debugging python (multi)processing (almirkaric.com) <li class="zemanta-article-ul-li"><a href="http://www.slideshare.net/royzimmer/you-can-do-it-start-using-perl-to-handle-your-voyager-needs">You Can Do It! Start Using Perl to Handle Your Voyager Needs (slideshare.net) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/b2b2afad-1679-46ab-831c-90ae0cc4d30f/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b14.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">

Continue reading