What Have You Done with Linux Lately?

Man of Honour
Soldato
Joined
2 Aug 2005
Posts
8,721
Location
Cleveland, Ohio, USA
I thought it might be fun to have a thread where we can discuss the little things that we use Linux to do that might otherwise be impracticable or otherwise needlessly difficult.

I'll go first.

This morning I was given a bunch of data on three dozen DVDs. He wanted me to copy all of the .zip files within a very deep system of subdirectories, found amid other types of files, then combine them into one large archive. He said it would probably take me several hours to track 'em all down. Little did he know! ;)

I needed just a few short commands to do the job and somebody who, unlike me, actually knows what they're doing could probably do it even easier.
essentially I ran:
Code:
find /cdrom/* | grep ".zip" > ~/Desktop/zipfiles.txt
Which, for those unfamiliar with such things is going to list all files in /cdrom, then search those results for .zip. It's going to then write the locations of those files to a text file on my desktop.

I popped open the file to see that it had indeed found a bunch of archives.
It then occurred to me that I could turn this into a little script. I went back to the command line and used sed:
Code:
sed 's/\/cdrom/mv\ \/cdrom/g' zipfiles.txt > mvscript.sh
This line uses sed, the Stream EDitor to search for /cdrom, the beginning of every path in the file, and replace it with mv /cdrom. All the of the backslashes are there to tell it to ignore the slashes and spaces which would confuse things. this is called escaping characters. I'll do the same sort of substitution for the end:
Code:
sed 's/.zip/.zip\ ~\/Desktop\/zipfiles/g' zipfiles.txt > mvscript2.sh
This replaces .zip with .zip ~/Desktop/zipfiles thus completing the move command. Now I just chmod +x mvscript2.sh and execute it and let the computer worry about navigating the nasty directories.

Since I had a lot of DVDs to go through I plopped all the commands I used into a single script which I ran after each disk automounted. In it I also ha Easy as pie and it let me get back to what's really important, playing networked dopewars. :D

I'm sure that if I had to do all this on Windows it would have taken hours.

So how about it, lads? Have you done anything cool with Linux lately to save you time, effort, or make you feel like some sort of demi-god, capable of solving all the world's problems with only a few keystrokes?
 
That's cool, marscay. How does it work? I haven't used lmsensor but I assume it prints the results of the sensors to standard I/O which you can then point to a file or grep or similar. How does your script manipulate this gleaned data? Share the goodness, it might give some of us some good ideas. :D
 
Nice scripts, seem useful as well for a change. :p I will be watching this thread, as I'm no script master myself. I can't seem to find any use for a script atm either. Any ideas? :D
Download Firefox over and over again for the next 15 or so hours. ;)

copy the following:
#!/bin/bash
while true ; do wget http: //MIRROR[/url] OF YOUR CHOICE/mozilla.org/firefox/releases/3.0/linux-i686/en-GB/firefox-3.0.tar.bz2; done

Go to Mozilla's site and find the address of a mirror that seems fast enough for you.
Open up nano or the text editor of your choice, paste it in with the relevant mirror address in place. Save it (ctrl o in nano). Exit and go back to the prompt (ctrl x in nano). run

chmod +x nameofscript

execute it with ./nameofscript

For extra fanciness you can run it with nohup and return control of your shell like so:
nohup ./nameofscript &&

P.S. Don't actually do this. It won't cont and puts unnecessary strain on their servers.
 
Last edited:
Built gcc ARM cross compiler (on my x86 linux box) for iphone native development and configured my toolchain correctly. Been busy working on iphone kernel development so not had much time to write linux stuff recently.
[accent=exaggerated Victorian , à la Futurama's Hedonismbot]Lah dee dah, I'm just too busy doing piddly ARM kernel development to toil with yon mere mortals. Lah de dah...[/accent]

:D

sablabra I've picked up what I know by finding some task to do then researching how it might be done. Basic shell scripting is essentially just a list of commands that you'd type at the command prompt. It executes one line then when that's done it executes the next. This is the stage I'm at. More advanced scripting uses variables and loops and conditional statements that, while not too difficult to understand when it's being explained, are a bit esoteric when starting with no programming experience.

I had to take a half semester course in C wherein the only thing I learned was that I didn't want to do programming again. As fate would have it I had another half semester course in Matlab that I was able to slog though by miming examples, not really understanding what I was doing.

There are plenty of shell scripting tutorials on the web. If anybody has read any and can recommend one for absolute beginners I'd love to know about it.
 
Don't mean to be a party pooper and what you did was a good way to learn but you could have just done this:

find /cdrom/ -name "*.zip" -exec cp {} /your/location

The find manpage should explain it all.
BillytheImpaler said:
...and somebody who, unlike me, actually knows what they're doing could probably do it even easier.
See! :D
 
How long did it take to compile the kernel? How much customization did you do to it, or did you just run with the base options as many do?

I assume that the hypervisor-crippled Cell still supports 64-bit operation. Is that what you're running? Does the proc and kernel support Altivec? If so it should have the guts to play most "scene" H.264 .mkv files.
 
If Nvidia can manage, I don't see why Creative can't. Nvidia's Linux drivers are pretty good.
They COULD manage, if they cared. They already have your money and they have darn near a monopoly on the discrete consumer-level sound processing market. They have little incentive to make any drivers that don't suck, particularly ones for Linux.

Vista's been out for what now, two and a half years? Creative STILL hasn't got non-sucking drivers for the platform.
 
Back
Top Bottom