![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| tail command and timestamp | Begins | Shell Programming and Scripting | 6 | 04-16-2008 02:17 AM |
| tail command.. | amon | Shell Programming and Scripting | 2 | 06-02-2006 04:36 AM |
| tail command | whatisthis | Shell Programming and Scripting | 3 | 03-31-2005 09:34 AM |
| PIPEs and Named PIPEs (FIFO) Buffer size | Jus | Filesystems, Disks and Memory | 1 | 08-20-2004 10:14 AM |
| tail command in SUN & HP_unix | clemeot | UNIX for Dummies Questions & Answers | 3 | 05-08-2002 11:31 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I am trying to using pipe (|) with ! (not) operator to list all the other files except the latest two and I am using the following command.
$ ls -ltr *.lst|!(tail -2) ksh: 20050211180252.lst: cannot execute but it is trying to execute the file returned by tail -2. I am able to do that in 4 steps 1) ls -ltr *.lst > listfile 2) numberoflines=`wc -l | cut -d" "` 3) ((numberoflines = numberoflines - 2)) 4) head -$numberoflines > final_list. Are there any Unix gurus who could help me write the above commands using pipe facility. I am using Korn shell. thanks in advance |
|
||||
|
this is the actual pseudocode for the script I am developing
log files are created by timestamp, so need to extract unique time stamps and save in a list file.. EXCEPT the latest two, then I need to archive those files in an Archive folder (moving). so that only the latest two remains in the .LOG folder. so I am doing. (awk '{print substr($9,1,14)} as filename is of 14 char.) cd $LOGDIR ls -ltr *.log |awk '{print substr($9,1,14)}'|sort -u|!(tail -2) > filenameslist I tried the following command suggested by one of the guru.. but it is throwing me an error. ls -ltr *.log |awk 'print substr($9,1,14)}'|sort -u|awk '{if (NR >3) print $0}' > filenameslist Thanks a lot guys for the valuable thougts.. can any body have a better Idea. challenge is to get it done using pipe.. I mean in one line |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|