Re: shell script question:How 2 assign several fields from a file to a variable?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



vick Julius wrote:

> Hello everybody
>
> I want to rename files with the new names from a text file, names.txt:
>
> Brazilian coffee
> Canadian maple
> Korean car
>
> i want to use the following script

As Rick mentioned, you will end up with only the one file.

> I want to renmae all files (in *.doc) with the new names read from
> names.txt file.
>
> The problem is the names in the file names.txt have spaces...

The only way I can think of is you will need to use an array to hold the
file names, see 'man bash' search for Arrays.  I think Perl would be more
like you friend here, or C if you can.

Another thing, spaces in *nix files just cause havoc; you would save
yourself a lot of future grief if you replaced the spaces with an
underscore  "blah_blah" or something.

Maybe you can do something to this effect: while looping through the
names.txt file, do a 'ls *.doc' and mv the first file to newname.blah,
ignoring the rest.  I don't know how you could do that, off hand, just a
thought, I still think an array would be easier. =P

--
Scott
-
: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux