|
Recursive Delete |
|
|
|
Written by Frank Sfalanga
|
|
Thursday, 20 May 2010 |
|
Sometimes I need to NOT delete some specific files but delete everything else. I need to save '4878c' but delete '4878cc' - and I need to do this recursively. for file in $( ls | grep -v '^4878c$'\ | grep -v '^4878c.map$'\ | grep -v '^4878c.qota1$'\ | grep -v '^4878c.qtta1$'\ | grep -v '^main.txt$'\ | grep -v '^samp.txt$'\ | grep -v '^tipresps$' ); do rm -rf $file; done This deletes EVERYTHING except the 7 specific files I want to preserve. |
|
|
Group Hunting |
|
|
|
Written by Frank Sfalanga
|
|
Monday, 07 December 2009 |
|
I use this whenever I need to scroll through all the existing groups on a server. It's handy if a particular group happens to have hundreds of members and screen real estate is miniscule # cat /etc/group | cut -d : -f 1 | less |
|
|
Creating & Spliting A Tarball Into 4.7G Pieces |
|
|
|
Written by Frank Sfalanga
|
|
Monday, 21 July 2008 |
|
Use this to create a tarball 4.7G at a time (perfect for writing to DVD) from the root "/" directory. sudo tar -cv -M --tape-length=4928307 --file=concord_home_7_18_08-1.tar /home/concord When prompted, create a second 4.7G file like this: Prepare volume #2 for concord_home_7_18_08-1.tar and hit return: n concord_home_7_18_08-2.tar Copy the files onto any new destination and combine them into a tarball which can be extracted normally using this: sudo tar -x -M --file=concord_home_7_18_08-1.tar largefile.tar Prepare volume #2 for concord_home_7_18_08-1.tar and hit return: n concord_home_7_18_08-2.tar Prepare volume #2 for concord_home_7_18_08-2.tar and hit return: Keep going until you get the completed "largefile.tar" then move it to the root "/" directory on the new hard drive and: sudo tar xvf largefile.tar
|
|
Last Updated ( Monday, 21 July 2008 )
|
|
Read more...
|
|
|
Delete oldest 107 files |
|
|
|
Written by Frank Sfalanga
|
|
Thursday, 17 January 2008 |
|
Get a list the files within the directory with the most recently accessed files at the bottom of the list
$ ls -ltur Count the number of files you want to keep - then get the file count for the directory $ ls -ltur | wc -l Delete the top 107 files from the directory. $ for file in $( ls -ltur | head -n107 | awk {'print $9'} ); do rm -rf $file; done |
|
Last Updated ( Sunday, 18 May 2008 )
|
|
|
Grep Away Comments |
|
|
|
Written by Frank Sfalanga
|
|
Wednesday, 16 January 2008 |
|
Sometimes when I'm searching huge config files like those of Samba or Apache it's easier to skip past all the comments. $ cat /etc/samba/smb.conf | grep -v \# <-- hides all lines with # anywhere in them (even at the end) $ cat /etc/samba/smb.conf | grep -v ^\# <-- hides only lines beginning with # |
|
Last Updated ( Sunday, 18 May 2008 )
|
|
|
|
<< Start < Prev 1 2 Next > End >>
|
| Results 1 - 9 of 13 |