[FM Discuss] Book idea: useful command lines

Sean DALY sdaly.be at gmail.com
Fri Oct 30 11:53:38 PDT 2009


I use awk and sed daily and Eric Piment's one-liners pages have been
invaluable to me.

I have found that what helps me figure out the syntax of what I have
to do is seeing a bunch of short examples together. Often, I
encapsulate awk or sed commands in a bash command.

Some one-liners are obscure but astonishingly useful. For example,
using subshells to compare lists without temp files, e.g. in
pseudocode
$ comm -3 <(a column cut from a table with record filenames) <(ls filenames)

or doing "history", then bringing up a command say #468 without
executing it, so as to adjust it:
$ !468:p

or inserting current PID in stdout redirect filename:
$ ls > myfilelist.$$.txt


Sean



On Fri, Oct 30, 2009 at 7:17 PM, Jeffrey Osier-Mixon <jefro at jefro.net> wrote:
> Hi all
>
> I suggest an FAQ format rather than a manual.  I am much more often asked
> "how do I do X" than "what does this command do".  Subsequent entries can
> build on previous ones.
> Here is a lame example:
> ___________________________________________________________________
> Q: Of the hundreds of random text files on my desktop, how can I determine
> where I wrote down how to spell my new niece's name?
>
> $ cd $HOME/Desktop; grep niece *
>
> That didn't locate anything.  I don't think I used the term "niece", but my
> brother's name is George.
>
> $ grep George *
>
> Q: That didn't work either, and her first birthday is coming up!  What shall
> I do?  What shall I do?
>
> $ grep -i george * | grep -i daughter
> to-do1234.txt: george's daughter's name is Ezmerelda
> ___________________________________________________________________
>
>
> The trick is figuring out what people are going to want to do, and
> presenting the items in a logical order rather than just a random list of
> "how do I" entries.  This example is about guessing what one's past self
> might have used as a search term that the future self would remember, but it
> might make sense to then follow up with better advice, and then explain what
> is going on in the example.
> ___________________________________________________________________
> Q: How am I going to remember her name and birthday in the future?
>
> One method is for your computer to remind you.  This example uses
> <code>cron</code>, a daemon that runs in the background and performs
> periodic tasks.  First, create a temporary text file to hold the entry (see
> "man 5 crontab" for details on cron entry syntax).  The example shows
> storing a message in a temporary file and then popping it up at the
> appropriate time, in this case noon on November 15 of any year.  Then
> install the new entry by running the <code>crontab</code> command.
>
> $ cat > new-cron
> 0 12 15 11 * 'cat "Ezmereldas birthday coming up on 12/1" > /tmp/foo ; xmore
> -display :0 /tmp/foo ; rm /tmp/foo'
> ^D
> $ crontab ./new-cron
>
> Note that these commands create a new crontab entry file, erasing previous
> entries.  To add more entries, or to edit this one:
>
> $ crontab -e
>
> To list all of your cron entries:
>
> $ crontab -l
> ___________________________________________________________________
>
>
> I would further suggest that this valuable subject could be best covered in
> a wiki rather than in a manual, so that readers can contribute by asking
> questions that the authors won't have considered.
>
> I hope this is useful!
>
>
> adam hyde wrote:
>>
>> i think this project, and Micks summation of the tourists guide to the
>> command line is cool...it might be interesting to send out emails asking
>> for peoples one-liners...there would be a tonne of interesting one
>> liners out there that i am sure people would like to contrib...formating
>> a good email and sending (where appropriate) to some lists might yield
>> interesting returns
>>
>> shall we create an empty manual for this? if so, what do we call it?
>>
>> adam
>>
>
> _______________________________________________
> Discuss mailing list
> Discuss at lists.flossmanuals.net
> http://lists.flossmanuals.net/listinfo.cgi/discuss-flossmanuals.net
>



More information about the Discuss mailing list