[Sussex] Future Talk [Was: Label and partition external hard drive]

D.Morris at brighton.ac.uk D.Morris at brighton.ac.uk
Mon Mar 7 11:00:29 UTC 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Actually, that command results in blank files :)  The following is correct

for file in `grep -HR "<david.morris at greenacre.no-ip.com>" * | grep -v Binary | grep -v .svn | cut
- -f1 -d:`; do sed 's/greenacre.no-ip.com/code-fish.co.uk/g' "$file" > "$file".new; mv "$file".new
"$file"; done



On 07/03/11 10:31, D.Morris at brighton.ac.uk wrote:
> Hi all,
> 
> Just been using this one liner which may inspire people to use the power of the CLI
> 
> I wanted to change my email address which was in lots of source files, and I'm too lazy to open
> every file, plus this is much quicker.
> 
> First of all I get a list of all the files which match my old email address, which I then strip of
> svn specific files and binaries.
> 
> Then for every result I grab the filename
> For every filename I use sed to replace the email domain, which I then echo out to replace the file.
> 
> 
> for file in `grep -HR "<david.morris at greenacre.no-ip.com>" * | grep -v Binary | grep -v .svn | cut
> -f1 -d:`; do sed 's/greenacre.no-ip.com/code-fish.co.uk/g' "$file" > "$file"; done
> 
> 
> 
> On 02/03/11 10:12, Dominic Humphries wrote:
>>> I've said it before but I will say it again: The power of the CLI comes
>>> from chaining commands together!
>>>
>>>     $ ps -ef | grep ^user | grep program | awk '{print "kill " $2}' | sh
>>>
>>> There!  A one line script to find a set of processes run by the same
>>> user account and kill them.  I took me a couple of minutes to build the
>>> script up, bit by bit more or less as I did above on site live.
> 
>> Another example that I use about a hundred times a day is this:
> 
>> function vai {
>>     found=`find . -path *$1 | grep -v blib | grep -v cache | grep -v .svn`
>>     vi $found
>>     }
> 
>> It lives in my .bashrc and gives me a new command, 'vai'
> 
>> What this does is search all your working directory's subdirs. for the filename you specify. So instead of having to type:
> 
>>   vi really/long/and/annoying/path/name/to/the/file/I/actually/want/to/edit.txt
> 
>> I can just type 
> 
>>   vai edit.txt
> 
>> Since there are dozens of files in all kinds of paths that I frequently need to edit, something as simple as this makes a huge difference to how quickly I can make edits. Especially when I know the filename I want but am not entirely sure of where exactly it is..
> 
>> The "find" gets the full pathname of matching files; The 'grep -v' parts strip out directories I don't want to look for files in. 
> 
>> If there's any GUI way to open files by name without having to specify the path, I would love to know about it.. It'd beat the hell out of all the double-clicking on folder icons :o)
> 
>> Dominic
> 
> 
>> --
>> Sussex mailing list
>> Sussex at mailman.lug.org.uk
>> E-mail Address: sussex at mailman.lug.org.uk
>> Sussex LUG Website: http://www.sussex.lug.org.uk/
>> https://mailman.lug.org.uk/mailman/listinfo/sussex
> 

___________________________________________________________
This email has been scanned by MessageLabs' Email Security
System on behalf of the University of Brighton.
For more information see http://www.brighton.ac.uk/is/spam/
___________________________________________________________

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk10uWMACgkQOtqu4mrzwougmQCaA7za52QB1znWb7dc2frANfV/
IN4An1Gky6m17OgxUzN8y33NBVbXQO47
=ywuw
-----END PGP SIGNATURE-----

___________________________________________________________
This email has been scanned by MessageLabs' Email Security
System on behalf of the University of Brighton.
For more information see http://www.brighton.ac.uk/is/spam/
___________________________________________________________



More information about the Sussex mailing list