Re: Need a command or script

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Dazed_75
Date:  
To: Main PLUG discussion list
Subject: Re: Need a command or script
On Tue, Dec 2, 2008 at 4:35 PM, der.hans <> wrote:
> Am 02. Dez, 2008 schwätzte Dazed_75 so:
>
> moin moin,
>
>> I know I could figure this out, and will tomorrow if no one gives me
>> the answer in the next hour. I have a file with many mv xxx yyy
>> commands and want to make another file with mv yyy xxx commands so
>> just need to swap the arguments. I have to go do some things now and
>> have a meeting tonight so would appreciate a reminder how to do this.
>> I know it is trivial but just don't remember how right now. Thanks in
>> advance.
>
> This command presumes there are no spaces in xxx and yyy and that yyy is
> the last thing on each command line. Adjust as necessary.
>
> $ echo mv xxx yyy | sed -re 's/ ([^[:space:]]+) ([^[:space:]]+)$/ \2 \1/'
> mv yyy xxx
>
> You could also use cut and some variable assignments.
>
> ciao,
>
> der.hans
> --

The source file contains real file names as the xxx and yyy dummys I
was trying to communicate so they would BE the variable names.
Basicly the source file contains mv commands to rename a whole bunch
of files and the file I need to create contains the commands to name
them back to the original names.

Sorry, I am late and have to run. Will check email once more before I
leave. Your command may well be right but I was surprised to see
actual xxx and yyys in there. I haven't used sed in maybe 20 years.

--
Man is the only animal that laughs and weeps, for he is the only
animal that is struck with the difference between what things are and
what they ought to be.
- William Hazlitt
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss