View Single Post
Old January 17th, 2013, 12:25 PM   #1 (permalink)
- Crazy peacock person -
Thread Author (OP)
MoodyBlues's Avatar
Join Date: Jan 2011
Location: echo $HOME; California
Posts: 2,784
Device(s): Kindle Fire HD 8.9" (rooted), Motorola Atrix 2, Motorola Atrix 4G (retired), Motorola Bravo (retired
Carrier: AT&T

Thanks: 927
Thanked 1,363 Times in 822 Posts
Cool The "Linux questions (and other stuff)" thread

With all the splintered discussions about Linux around here, I thought perhaps we could have a thread dedicated to all things Linux. Whether you're a new Linux user, or someone considering installing Linux, or have specific questions or solutions about a Linux feature or program, how about posting here? I'll start by pasting in some code I posted in a totally non-computer related thread!

The following bash code will replace spaces in file names with underscores:


ls > /tmp/current_files
mv /tmp/current_files ./current_files
cat current_files | tr ' ' '_' > current_files_new
FileCount=$(wc -l current_files | awk '{print $1}')
while [ "$count" -le "$FileCount" ]
do ReadAwk="FNR=="$count
OldName=$(awk $ReadAwk current_files)
NewName=$(awk $ReadAwk current_files_new)
mv "$OldName" "$NewName" > /dev/null 2>&1
rm current_files
rm current_files_new
exit 0[/high]

My advice is that you try it first in a temporary directory with copies of files, just to verify for yourself that it works as expected. Also, if you're unsure what any part of it does, feel free to ask.
Info on Heartbleed bug; updated with helpful links

MoodyBlues is offline  
Reply With Quote
The Following 6 Users Say Thank You to MoodyBlues For This Useful Post:
9to5cynic (January 17th, 2013), alostpacket (January 18th, 2013), argedion (January 17th, 2013), Davdi (January 18th, 2013), Speed Daemon (January 18th, 2013), Stinky Stinky (October 7th, 2013)