LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Blogs > sag47
User Name
Password

Notices



Uncategorized Entries with no category
Old

Simulate -print0 with ls

Posted 09-07-2011 at 04:39 AM by sag47
Tags find

Recently I wanted to manipulate files only in the current directory (not sub-directories). I usually use the following combination...

Code:
find . -type f -print0 | xargs -0 somecommand
The only problem I had with that was it ran through all sub-directories as well. Then I remembered the -m switch for ls and decided to depend on my good old friend sed.

Code:
ls -m | sed 's/, /\x0/g' | xargs -0 somecommand
Though I guess it would be better to do it...
Senior Member
Posted in Uncategorized
Views 1637 Comments 0 sag47 is offline
Old

rsync commands and how I backup

Posted 06-23-2011 at 06:06 PM by sag47
Updated 06-23-2011 at 06:07 PM by sag47

I run the following command when I want to just update one directory to another. It only copies files that have changed. If any files have been deleted from A they still exists in directory B. The trailing slash after A/ is necessary to tell rsync to move the contents. Otherwise A will create a folder in B called /media/B/A and move the files over.

Code:
rsync -ruptv /media/A/ /media/B
I run the following command when I want to mirror one directory to another. Any files...
Senior Member
Posted in Uncategorized
Views 692 Comments 0 sag47 is offline
Old

Convert and resize images using imagemagick

Posted 05-30-2011 at 11:07 PM by sag47
Updated 05-31-2011 at 02:23 AM by sag47

This past memorial day weekend I took a bunch of pictures which I wanted to post to the web. Web photos are best viewed in 800x600px and I had a lot of them. So I used a simple command to do it.
Code:
for x in `ls -1`;do convert -resize 800x600 $x `echo $x | sed 's/.JPG/.png/'`;done
mkdir web_album
for x in `ls -1 *.png`;do convert $x web_album/`echo $x | sed 's/.png/.jpg/'`;done
rm *.png
Now I don't have to spend all my time in Gimp with that simple batch command.
Senior Member
Posted in Uncategorized
Views 4287 Comments 1 sag47 is offline
Old

DVD Ripping

Posted 04-25-2011 at 11:54 AM by sag47

I work for a Scientific Institution and a company which recorded talks decided to give us all the talks in DVD format instead of a hard drive full of video files. This is kind of counter intuitive however luckily I use Linux at work. Long story short mencoder with lame installed solved my problems.

Code:
mencoder 
-vf harddup 
-vf-add smartblur=.6:-.5:0,unsharp=l5x5:.8:c5x5:.4 
-xvidencopts fixed_quant=4:profile=dxnhtntsc 
-lameopts cbr:br=128:aq=0:vol=1
...
Senior Member
Posted in Uncategorized
Views 3310 Comments 1 sag47 is offline
Old

MAC Mania

Posted 04-07-2011 at 03:01 PM by sag47
Tags syslog

Today I was having mac address problems. My corp network runs a mac filtered domain so in order to avoid the hassle of contacting IT (which are stupid) I simply copied the macs from other machines and issued them to my servers (I'm a technical head for my department). Well I didn't save the MAC address and the server was shutdown when we moved it which blew away the mac. What did I do? Search the logs for every MAC address ever.

Code:
find . -type f -print0 | xargs -0 grep -iH '\([0-9a-f]\{2\}[:-]\)\{5\}[0-9a-f]\{2\}\|[0-9a-f]\{12\}'
...
Senior Member
Posted in Uncategorized
Views 777 Comments 0 sag47 is offline

  



All times are GMT -5. The time now is 02:49 PM.

Main Menu
Advertisement

Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration