Challenging Shell Script

Challenging Shell Script

am 03.09.2005 10:38:03 von vick Julius

I have a folder of digital images MV1000.jpg, MV1001.jpg, MV1002.jpg,....
These images correspond to a list of hardware items. This list is in a text
file items.txt as follow:


ID Description // this line can be removed from the file
500 screw driver philips
501 camera digital canon
502 laser printer samsung
etc...

The image MV1000.jpg corresponds to the first item in the list, i.e. 500
screw driver philips and the second image, MV1001.jpg corresponds to the
second item in the list, i.e. 501 camera digital canon and so on.


I want to rename the images in the following way:

The name of each image should be made of: 3 letters which are the first
letters of each word in the line from items.txt file (screw driver philips
would be sdp) followed by the ID of the item.

For example:




MV1000.jpg should be sdp500.jpg
MV1001.jpg should be cdc501.jpg
MV1002.jpg should be lps502.jpg



Thank you

Vick

____________________________________________________________ _____
Don't just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/

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

Re: Challenging Shell Script

am 03.09.2005 15:08:17 von Arvind

--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

> This list is in a text file items.txt as follow:
>=20
> 500 screw driver philips
> 501 camera digital canon
> 502 laser printer samsung
> etc...

sed 's/\([0-9]*\) *\(.\)[^ ]* *\(.\)[^ ]* *\(.\).*/\2\3\4\1/' items.txt

I'll let you do the rest.

Arvind
--=20
Everyone is more or less mad on one point.
-- Rudyard Kipling

--6TrnltStXW4iwmi0
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDGaBBoaZeAZF2ZYcRAjYsAKCMtlcexeIa4qSeJGmaBBxtOnbxKwCf Q6tA
/lE60YAcQUmTQX6q0WNzWKc=
=+RU3
-----END PGP SIGNATURE-----

--6TrnltStXW4iwmi0--
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html