Need a command or script
Dazed_75
lthielster at gmail.com
Tue Dec 2 16:45:46 MST 2008
On Tue, Dec 2, 2008 at 4:35 PM, der.hans <PLUGd at lufthans.com> 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
More information about the PLUG-discuss
mailing list