Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick one-liner

Status
Not open for further replies.

BIS

Technical User
Jun 1, 2001
1,893
NL
Hallo,

Suppose I have a file named jkl678%Km93 which looks like this:

Subject: XX-Date
Some text
Some randon numbers
more text

how can I easily rename this file from 'jkl678%Km93' to 'XX-Date' (the text after the Subject: line)
 
Code:
for file in *
do
  mv $file $(awk '/Subject/ {print $2}' $file)
done
It's a bit short of error checking etc...

On the internet no one knows you're a dog

Columb Healy
 
It does what I need - many thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top