- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2005 01:39 AM
07-12-2005 01:39 AM
Iam having some difficulty with an awk statement. Within a certain dir I want to rename all WUK<8_digits>.dat files TAR<8_digits>.dat, duplicating the WUK files but replacing the TAR with WUK in the filename.
I have tried:
for i in `ll| awk '{ print $4 $15 }' WUK*`
do
cp WUK$i TAR$i
done
.....but no joy???
Rgds,
D.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2005 01:57 AM
07-12-2005 01:57 AM
Re: awk script
do
cp -p $i `echo $i | sed -e "s/WUK/TAR"`
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2005 02:06 AM
07-12-2005 02:06 AM
Re: awk script
Thanks for the speedy response! I am now getting the following output from the debug:
+ sed -e s/WUK/TAR
+ echo WUK????????.dat
sed: Function s/WUK/TAR cannot be parsed.
+ cp -p WUK????????.dat
Usage: cp [-f|-i] [-p] [-S] [-e warn|force|ignore] source_file target_file
cp [-f|-i] [-p] [-S] [-e warn|force|ignore] source_file ... target_direc
tory
cp [-f|-i] [-p] [-S] -R|-r [-e warn|force|ignore] source_directory ... t
arget_directory
Rgds,
D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2005 02:13 AM
07-12-2005 02:13 AM
Re: awk script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2005 02:19 AM
07-12-2005 02:19 AM
Solutionfor i in WUK????????.dat
do
cp -p $i `echo $i | sed s/WUK/TAR`
done
Run ...
testhost:/tmp/junk/ for i in WUK????????.dat; do cp -p $i `echo $i | sed s/WUK/TAR/`; done
testhost:/tmp/junk/ ls -al
total 0
-rw-r--r-- 1 root sys 0 Jul 12 11:12 TAR12335678.dat
-rw-r--r-- 1 root sys 0 Jul 12 11:11 TAR12345678.dat
-rw-r--r-- 1 root sys 0 Jul 12 11:12 WUK12335678.dat
-rw-r--r-- 1 root sys 0 Jul 12 11:11 WUK12345678.dat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2005 02:26 AM
07-12-2005 02:26 AM
Re: awk script
You can do it without using awk. Try this:
for i WUK*
do
n=${i##WUK}
cp $i TAR${n}
done
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2005 02:30 AM
07-12-2005 02:30 AM
Re: awk script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2005 02:37 AM
07-12-2005 02:37 AM
Re: awk script
Kind Rgds,
D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2005 02:51 AM
07-12-2005 02:51 AM
Re: awk script
This is pretty small and does the job.
for i in WUK*; do cp $i ${i/#WUK/TAR}; done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2005 07:00 AM
07-12-2005 07:00 AM
Re: awk script
You can use this one-liner awk program.
# ls -1 WUK[0-9]*.dat | awk -F"WUK" '{system("cp "$0" TAR"$2)}'
cheers!