guess I thought it worked like rm -i where it prompts every time. but as far as I know gentoo doesn't set that alias. Infact I'm not sure I've seen them set any. I you want them, you set them yourself. but anyways my confusion.
<br><br><div><span class="gmail_quote">On 4/8/06, <b class="gmail_sendername">Bruce Smith</b> <<a href="mailto:blubdog@gmail.com">blubdog@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
"mv -i" only prompts to overwrite when the destination filename<br>exists. Without the "-i", mv will silently nuke the existing dest.<br>file.<br><br>Most distros have an alias in the default login script of "mv" to "mv
<br>-i" (and "cp" to "cp -i") which is why you may be seeing that<br>behaviour in the shell now. However aliases don't carry over to shell<br>scripts, so you need to be careful.<br><br> - BS<br><br>
<br>On 4/8/06, Caleb Cushing <<a href="mailto:xenoterracide@gmail.com">xenoterracide@gmail.com</a>> wrote:<br>> I actually do have another question about this script. why doesn't mv -i<br>> prompt me before changing the files when it's run like this?
<br>><br>><br>> On 4/7/06, Alec Warner <<a href="mailto:warnera6@egr.msu.edu">warnera6@egr.msu.edu</a>> wrote:<br>> > Caleb Cushing wrote:<br>> > > haven't tried it yet backing up the directory into a tarball that'll
<br>> take a<br>> > > while. Do you think you could comment it for me? basically programming<br>> of<br>> > > any kind is a weak point for me. I'm trying to improve. but copying and<br>> > > pasting someone elses code may fix my issue but it won't fix my
<br>> > > understanding. "give a man a fish... teach a man to fish..." sort of<br>> thing.<br>> > ><br>> > >><br>> > >><br>> > >>On 4/6/06, Bruce Smith <
<a href="mailto:blubdog@gmail.com">blubdog@gmail.com</a>> wrote:<br>> > >><br>> > >>>Disclaimer, backup the directory first! :-)<br>> > >>>And copy/paste exactly!<br>> > >>>
<br>> > >>>You can test without changing anything by adding an "echo" in front of<br>> > >>>the "mv" and optionally commenting out the "set" statements for better
<br>> > >>>readability.<br>> > >>><br>> > >>>One bug (feature?) is it will replace multiple spaces with only ONE<br>> > >>>underscore.<br>> > >>><br>
> > >>>You need to run it with the filename(s) as arguments. i.e.:<br>> > >>> /path/to/scriptname *<br>> > >>> /path/to/scriptname a*<br>> > >>> /path/to/scriptname 'File to Test this Thing
on.TXT'<br>> > >>><br>> > >>>- BS<br>> > >>><br>> > >>><br>> > >>>#!/bin/sh # Run using /bin/sh, the Bourne Shell<br>> > >>>infile=upper
<br>> > >>>outfile=lower<br>> > >>>for f # Not sure where 'f' comes from, but it's looping<br>> throught the standard input, IIRC<br>> > >>>do<br>> > >>> if [ -f "$f" ]; then # man test will tell you what this does ;)
<br>> > >>> l="$(echo $f|sed 's/ /_/g'|tr "[:${infile}:]"<br>> "[:${outfile}:]")" # echo file, change ' ' to '_', globally, change upper to<br>> lower<br>> > >>>
<br>> > >>> if [ "$f" != "$l" ]; then # If the new filename doesn't equal<br>> the old filename..<br>> > >>> set -x # turn off echo<br>
> > >>> mv -i "$f" "$l" # rename the file<br>> > >>> set +x # turn echo back on<br>> > >>> fi<br>> > >>> fi
<br>> > >>>done<br>> > >>># end of script<br>> > >>><br>> > >>><br>> > >>>On 4/6/06, Caleb Cushing < <a href="mailto:xenoterracide@gmail.com">xenoterracide@gmail.com
</a>> wrote:<br>> > >>><br>> > >>>>I need/want to change the names of all the files and folders in my<br>> > >>><br>> > >>>/music<br>> > >>>
<br>> > >>>>directory to where they don't have spaces in them and all the names<br>> > >>><br>> > >>>are in<br>> > >>><br>> > >>>>lowercase. This is what I have so far:
<br>> > >>>><br>> > >>>>#!/bin/bash<br>> > >>>><br>> > >>>>ls -R | # List directory recursively<br>> > >>>>sed -e 's/ /_/g' | # Remove spaces change them to
<br>> > >>><br>> > >>>underscore<br>> > >>><br>> > >>>>tr [:upper:] [:lower:] | #change letters from upper to lower<br>> > >>>><br>> > >>>>that gives me the output of what I would want the directory and file
<br>> > >>>>structure to look like when I'm done. I am unsure however how to take<br>> > >>><br>> > >>>that<br>> > >>><br>> > >>>>output and move the files and directories to acually look like that
<br>> > >>><br>> > >>>when I<br>> > >>><br>> > >>>>am finished. It's also the tricky part because if I don't do it<br>> > >>><br>> > >>>right...
<br>> > >>><br>> > >>>>well it might be an even bigger pain to fix. I pretty sure I have a<br>> > >>><br>> > >>>lot more<br>> > >>><br>> > >>>>to do to get this workable... and I'm just having problems wrapping my
<br>> > >>><br>> > >>>brain<br>> > >>><br>> > >>>>around it.<br>> > >>>><br>> > >>>>snippet:before<br>> > >>>>#ls -R
<br>> > >>>><br>> > >>>>./3 Doors Down:<br>> > >>>>Away from the Sun Seventeen Days The Better Life Thumbs.db<br>> > >>><br>> > >>>desktop.ini
<br>> > >>><br>> > >>>>./3 Doors Down/Away from the Sun:<br>> > >>>>01-When I'm Gone-3 Doors Down-Away from the Sun.mp3<br>> > >>>>02-Away from the Sun-3 Doors Down-Away from the
Sun.mp3<br>> > >>>>03-The Road I'm On-3 Doors Down-Away from the Sun.mp3<br>> > >>>>04-Ticket to Heaven-3 Doors Down-Away from the Sun.mp3<br>> > >>>>05-Running Out of Days-3 Doors Down-Away from the
Sun.mp3<br>> > >>>>06-Here Without You-3 Doors Down-Away from the Sun.mp3<br>> > >>>>07-I Feel You-3 Doors Down-Away from the Sun.mp3<br>> > >>>>08-Dangerous Game-3 Doors Down-Away from the
Sun.mp3<br>> > >>>>09-Changes-3 Doors Down-Away from the Sun.mp3<br>> > >>>>10-Going Down in Flames-3 Doors Down-Away from the Sun.mp3<br>> > >>>>11-Sarah Yellin'-3 Doors Down-Away from the
Sun.mp3<br>> > >>>> AlbumArtSmall.jpg<br>> ><br>> >>>>AlbumArt_{C212FF41-147D-402C-BAC5-1284F8B4C802}_Large.jpg<br>> ><br>> >>>>AlbumArt_{C212FF41-147D-402C-BAC5-1284F8B4C802}_Small.jpg
<br>> > >>>>Folder.jpg<br>> > >>>> Thumbs.db<br>> > >>>>desktop.ini<br>> > >>>><br>> > >>>>snippet:after<br>> > >>>>
<br>> > >>>>ls -R<br>> > >>>><br>> > >>>>./3_doors_down:<br>> > >>>>away_from_the_sun<br>> > >>>>seventeen_days<br>> > >>>>the_better_life
<br>> > >>>>thumbs.db<br>> > >>>>desktop.ini<br>> > >>>><br>> > >>>>./3_doors_down/away_from_the_sun:<br>> > >>>>01-when_i'm_gone-3_doors_down-away_from_the_sun.mp3
<br>> ><br>> >>>>02-away_from_the_sun-3_doors_down-away_from_the_sun.mp3<br>> > >>>>03-the_road_i'm_on-3_doors_down-away_from_the_sun.mp3<br>> ><br>> >>>>04-ticket_to_heaven-3_doors_down-away_from_the_sun.mp3
<br>> ><br>> >>>>05-running_out_of_days-3_doors_down-away_from_the_sun.mp3<br>> ><br>> >>>>06-here_without_you-3_doors_down-away_from_the_sun.mp3<br>> > >>>>07-i_feel_you-3_doors_down-away_from_the_sun.mp3
<br>> > >>>>08-dangerous_game-3_doors_down-away_from_the_sun.mp3<br>> > >>>>09-changes-3_doors_down-away_from_the_sun.mp3<br>> ><br>> >>>>10-going_down_in_flames-3_doors_down-away_from_the_sun.mp3
<br>> > >>>>11-sarah_yellin'-3_doors_down-away_from_the_sun.mp3<br>> > >>>>albumartsmall.jpg<br>> ><br>> >>>>albumart_{c212ff41-147d-402c-bac5-1284f8b4c802}_large.jpg
<br>> ><br>> >>>>albumart_{c212ff41-147d-402c-bac5-1284f8b4c802}_small.jpg<br>> > >>>>folder.jpg<br>> > >>>>thumbs.db<br>> > >>>>desktop.ini<br>> > >>>>
<br>> > >>>>_______________________________________________<br>> > >>>>linux-user mailing list<br>> > >>>> <a href="mailto:linux-user@egr.msu.edu">linux-user@egr.msu.edu
</a><br>> ><br>> >>>><a href="http://mailman.egr.msu.edu/mailman/listinfo/linux-user">http://mailman.egr.msu.edu/mailman/listinfo/linux-user</a><br>> > >>>><br>> > >>>>
<br>> > >>>><br>> > >>><br>> > >><br>> > ><br>> > ><br>> > ><br>> ------------------------------------------------------------------------<br>> > >
<br>> > > _______________________________________________<br>> > > linux-user mailing list<br>> > > <a href="mailto:linux-user@egr.msu.edu">linux-user@egr.msu.edu</a><br>> > > <a href="http://mailman.egr.msu.edu/mailman/listinfo/linux-user">
http://mailman.egr.msu.edu/mailman/listinfo/linux-user</a><br>> ><br>><br>><br>> _______________________________________________<br>> linux-user mailing list<br>> <a href="mailto:linux-user@egr.msu.edu">
linux-user@egr.msu.edu</a><br>> <a href="http://mailman.egr.msu.edu/mailman/listinfo/linux-user">http://mailman.egr.msu.edu/mailman/listinfo/linux-user</a><br>><br>><br>><br></blockquote></div><br>