[clug] Command of the Hour

Kim Holburn kim.holburn at gmail.com
Tue Sep 23 06:25:24 GMT 2008

A command I like and is very useful at times and which I sometimes  
forget is script.

You type:
script fred.txt

After the script command you are in a normal subshell and until you  
type an "exit" command everything that appears on the screen gets  
appended to the file you specified (fred.txt in this case).

It can be really useful to remember or show someone a sequence of  

On 2008/Sep/23, at 1:00 AM, Nathan Rickerby wrote:

> On Tue, Sep 16, 2008 at 08:10:18AM +1000, Brett Worth wrote:
>> One I use a lot is fmt.  If I'm editing text in vi I normally use  
>> "set wm=5" to get the
>> line wrapping at the 5th to last column.  After making changes  
>> though the formatting gets
>> out of whack.  I then use the "!" with a moving command to send a  
>> block of the file
>> through "fmt". e.g.
>> 	{      -  Go to the blank line before a paragraph.
>> 	!}fmt  -  Send the paragraph through fmt.
> Something similar that also works quite well is par
> http://www.nicemice.net/par/ it handles multiple levels of quoting
> characters which is really handy for email.
> One vi command I like is !!sh to execute the current line in a shell.
> It's useful if you're building up a long one-liner and want to easily
> document the output and your progress.  Or if you want to include the
> output of previous commands in future commands, for example
> ls *txt<esc>!!sh
>  edit the output, insert cat at the front of the line and | grep  
> whatever at
>  the end of the line, then
> <esc>!!sh
> I find it easier to use than :r!
> also !!dc for a calculator, for example
> 4534 445 * 5 / 2 + p<esc>!!dc
> and again you can use the output of that in your next calculation.
> It probably doesn't need need pointing out, but if you yyp before you
> !!dc you can keep a copy of the input.
> On Tue, Sep 16, 2008 at 11:06:11AM +1000, Jeremy Kerr wrote:
>>> And sudo tee
>>> Because `sudo echo foo > file` won't work when you don't have
>>> permission to change file, the shell does the redirection.
>>> `echo foo | sudo tee file` will work for you.
>> I use dd for this:
>> echo 1 | sudo dd of=/proc/sys/net/ipv4/ip_forward
>> - which gives you the same semantics as bash redirection (ie, the  
>> output
>> isn't copied to stdout)
> As much as I appreciate that use of dd, tee has the advantage that you
> can use the -a option to append to the file like >>.
> -- 
> linux mailing list
> linux at lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux

Kim Holburn
IT Network & Security Consultant
Ph: +39 06 855 4294  M: +39 3494957443
mailto:kim at holburn.net  aim://kimholburn
skype://kholburn - PGP Public Key on request

More information about the linux mailing list