- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: syntax error at line
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
Forums
Discussions
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
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
10-11-2011 03:25 AM
10-11-2011 03:25 AM
Hi!
I am trying to create a script tha copies files from one directory to the other on the same system, like this:
for JOB in `ls -lrt | awk '{if ($6 == "Aug" && $8 != 2010)print $9}'`
cp -p /data/xxxx/yyyy/zzzz/processed/$JOB /data/xxxx/yyyy/zzzz/processed/Ago11/
done
But I am having the following error:
Syntax error at line 2 : `cp' is not expected
Please can you help
FR
Solved! Go to Solution.
- Tags:
- for loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2011 03:28 AM
10-11-2011 03:28 AM
SolutionHi:
The problem is that 'do ... done' needs to define the loop. You are missing the 'do'.
for JOB in `ls -lrt | awk '{if ($6 == "Aug" && $8 != 2010)print $9}'`
do
cp -p /data/xxxx/yyyy/zzzz/processed/$JOB /data/xxxx/yyyy/zzzz/processed/Ago11/
doneRegards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2011 04:33 AM
10-11-2011 04:33 AM
Re: syntax error at line
Hi
Sorry, my stupid mistake...
its now working
thanks a lot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2011 02:46 AM
10-12-2011 02:46 AM
Re: syntax error at line
Or if you like, you can put the do on the for line:
for JOB in $(ls -lrt | awk '{if ($6 == "Aug" && $8 != 2010) print $9}'); do
cp -p /data/xxxx/yyyy/zzzz/processed/$JOB /data/xxxx/yyyy/zzzz/processed/Ago11/
done