tee to a file descriptor

2010-08-13 1 min read Bash Linux

tee to a file descriptor

1
$ tee >(cat – >&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

when you press f9 'paste' is on , press f9 again and 'paste' is off, and so forth (works in insert-mode and command-mode)

2010-08-02 1 min read Bash Linux

<a class="zem_slink" title="Vim (text editor)" rel="homepage" href="http://www.vim.org/">vim&#8217;s pastetoggle: when you press f9 &#8217;paste&#8217; is on , press f9 again and &#8217;paste&#8217; is off, and so forth (works in <a class="zem_slink" title="Insert key" rel="wikipedia" href="http://en.wikipedia.org/wiki/Insert_key">insert-mode and command-mode) $ nmap :set paste!:set paste? Sets as paste toggle, with visual confirmation of state

* View this command to comment, vote or add to favourites * View all commands by Vilemirth

commandlinefu.com

by David Winterbottom (codeinthehole.com)

Continue reading

List of commands you use most often

2010-07-25 1 min read Bash Linux

$ history | <a class="zem_slink" title="AWK" rel="homepage" href="http://cm.bell-labs.com/cm/cs/awkbook/index.html">awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head > /tmp/cmds | <a class="zem_slink" title="Gnuplot" rel="homepage" href="http://www.gnuplot.info/">gnuplot -persist <(echo 'plot "/tmp/cmds" using 1:xticlabels(2) with boxes') Plot your most used commands with gnuplot.

  • <a href="http://www.commandlinefu.com/commands/view/5845/list-of-commands-you-use-most-often">View this command to comment, vote or add to favourites
  • <a href="http://feeds2.feedburner.com/commands/by/sthrs">View all commands by <a href="http://feeds2.feedburner.com/commands/by/sthrs">sthrs

<a href="http://www.commandlinefu.com">

by David Winterbottom (<a href="http://codeinthehole.com">codeinthehole.com)

<a href="http://feedads.g.doubleclick.net/~a/qns5iNy–6jXLRCLFY_jGnkB68s/0/da">
<a href="http://feedads.g.doubleclick.net/~a/qns5iNy–6jXLRCLFY_jGnkB68s/1/da">

Continue reading

Upload a video to youtube

2010-07-16 1 min read Linux Uncategorized

<span style="font-size: x-large;"><a href="http://feedproxy.google.com/~r/Command-line-fu/~3/JXJj-wy4keA/upload-a-video-to-youtube">Upload a video to youtube

$ google youtube post –title "My Video" –category Education ~/myvideo.avi <a class="zem_slink freebase/guid/9202a8c04000641f800000000042acea" title="Google" rel="homepage" href="http://google.com">Google just released a new commend line tool offering all sorts of new services from the commend line. One of them is uploading a <a class="zem_slink freebase/guid/9202a8c04000641f8000000000982f58" title="YouTube" rel="homepage" href="http://www.youtube.com/">youtube video but there are plenty more google services to interact with.

<a class="zem_slink freebase/guid/9202a8c04000641f8000000000054c6a" title="Uploading and downloading" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uploading_and_downloading">Download it here: <a href="http://code.google.com/p/googlecl/">http://code.google.com/p/googlecl/

Continue reading

concatenate compressed and uncompressed logs

2010-07-15 1 min read Bash Fedora Linux

<span style="font-size: x-large;"><a href="http://feedproxy.google.com/~r/Command-line-fu/~3/iwFUyltYgjM/concatenate-compressed-and-uncompressed-logs">concatenate compressed and uncompressed logs

$ find /var/log/apache2 -name 'access.loggz' -exec <a class="zem_slink freebase/guid/9202a8c04000641f800000000001abd9" title="Gzip" rel="homepage" href="http://www.gzip.org/">zcat {} ; -or -name 'access.log' -exec cat {} ; This command allows you to stream your log files, including gziped files, into one stream which can be piped to <a class="zem_slink freebase/guid/9202a8c04000641f800000000000584b" title="AWK" rel="homepage" href="http://cm.bell-labs.com/cm/cs/awkbook/index.html">awk or some other command for analysis.

Note: if your version of &#8217;find&#8217; supports it, use:

Continue reading

List of commands you use most often

2010-06-16 1 min read Bash Learning

<span style="font-size: x-large;"><a href="http://feedproxy.google.com/~r/Command-line-fu/~3/6MxHiSiINdo/list-of-commands-you-use-most-often">List of commands you use most often

$ history | <a class="zem_slink freebase/en/awk" title="AWK" rel="homepage" href="http://cm.bell-labs.com/cm/cs/awkbook/index.html">awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head > /tmp/cmds | gnuplot -persist <(echo 'plot "/tmp/cmds" using 1:xticlabels(2) with boxes') Plot your most used commands with gnuplot.

  • <a href="http://www.commandlinefu.com/commands/view/5845/list-of-commands-you-use-most-often">View this command to comment, vote or add to favourites
  • <a href="http://feeds2.feedburner.com/commands/by/sthrs">View all commands by <a href="http://feeds2.feedburner.com/commands/by/sthrs">sthrs

<a href="http://www.commandlinefu.com"><img src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/header-logo.jpg" alt="commandlinefu.com" align="bottom" />

Continue reading

let a cow tell you your fortune

2010-06-03 1 min read Bash Linux
Here\’s something that I saw on commandlinefu yesterday. That sent me thinking about some command to have the cow file picked randomly 🙂 So, here\’s the original command from the commandlinefu:

let a cow tell you your fortune

    <td>
      <div class="text codecolorer">
        $ fortune | <a class="zem_slink freebase/en/cowsay" title="Cowsay" rel="homepage" href="http://www.nog.net/%7Etony/warez/cowsay.shtml">cowsay</a> -f tux
      </div>
    </td>
  </tr>
</table>
1