- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk issue
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
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
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
03-22-2011 12:52 AM
03-22-2011 12:52 AM
I´m not very familiar with scripting, Í am still learning.
Please can someone tell me what could be wrong with that command:
root@nrtrde1 # ls -lrt | awk '{if ($6 == "Jan") && ($7 == "1")print $9}'
awk: syntax error near line 1
awk: illegal statement near line 1
The idea is to list all files of 1st of january 2011. If I am able to do this I could write a script to transfer files from january 2011.
Your help is appreciated
F.R.
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2011 01:01 AM
03-22-2011 01:01 AM
Re: awk issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2011 01:06 AM
03-22-2011 01:06 AM
Re: awk issue
>>ls -lrt | awk '{if($7 == "1")if ($7==1) print $9}'
Sorry the first if shouldn´t be "Jan" as opposed to what you wrote which is "1"?
F.R.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2011 01:21 AM
03-22-2011 01:21 AM
Re: awk issue
ls -lrt | awk '{if($6 == "Jan")if ($7==1) print $9}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2011 04:00 AM
03-22-2011 04:00 AM
Re: awk issue
It does work now, but how if I want to exclude from that list all january 2010 files, because now is listing me all january 1st 2010 files, but what I want is January 2011.
F.R.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2011 04:15 AM
03-22-2011 04:15 AM
Re: awk issue
Proper awk IMHO is a series of conditions follows by code blocks.
The example unconditionally goes into a codeblock and then starts a condition.
Try this: $ ls -ltr | awk '($6=="Jan") && ($7==1) {print $9}'
Not for the real problem you do NOT want to use awk.
You want to use FIND.
Check out the -ctime option, or the usage of 'reference files' through the -newer and -older options.
Google and the MAN PAGES are your friend in this learning exercise.
Cheers,
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2011 04:47 AM
03-22-2011 04:47 AM
Re: awk issue
If you need some date filter, use find:
find /home/usersname -type f -mtime +5 -exec ls -ls {} \;
or something similar.
Good luck !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2011 06:20 AM
03-22-2011 06:20 AM
Re: awk issue
# touch -amt 201012312359.59 /tmp/ref1
# touch -amt 201101012359.59 /tmp/ref2
# find . -type f -newer /tmp/ref1 -a ! -newer /tmp/ref2
...will list the files *last_modified* on January 1, 2011
See the manpages for 'touch(1)' and for 'find(1)'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2011 09:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2011 10:50 PM
03-22-2011 10:50 PM
Re: awk issue
Dennis:
Your suggestion give me this:
-rw-r--r-- 1 taprap other 60414 Jan 1 2010 CDNAM01MOZ0105105
-rw-r--r-- 1 taprap other 123 Jan 1 2010 CDMWICPMOZ0103249
-rw-r--r-- 1 taprap other 1698 Jan 1 2010 CDISRCLMOZ0103103
-rw-r--r-- 1 taprap other 129 Jan 1 01:34 CDINDA9MOZ0101336
-rw-r--r-- 1 taprap other 3516 Jan 1 01:34 CDZMBCEMOZ0103029
-rw-r--r-- 1 taprap other 129 Jan 1 01:35 CDINDJBMOZ0102144
-rw-r--r-- 1 taprap other 647 Jan 1 01:35 CDINDA2MOZ0101581
-rw-r--r-- 1 taprap other 123 Jan 1 01:36 CDGRCPFMOZ0105837
-rw-r--r-- 1 taprap other 123 Jan 1 01:36 CDPRYHTMOZ0101023
BUT I do not want the 2010 files, I just want the other files. How can I get rid of the Jan 1 2010 files?
F.R.