02-15-2005
Thanks guys.. but still I am not getting the correct result
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
10 More Discussions You Might Find Interesting
1. Filesystems, Disks and Memory
Hello!
How I can increase or decrease predefined pipe buffer size?
System FreeBSD 4.9 and RedHat Linux 9.0
Thanks! (1 Reply)
Discussion started by: Jus
1 Replies
2. Shell Programming and Scripting
Hi ,
I have found a interesting thing about tail command:
when I tried to use 'tail -1 *' to look at every file with the current derectory, I only got one line of result of one file.
But if I use 'head -1 *', I would get multiple lines.
Is there a way to do get multiple lines with 'tail -1 *'... (3 Replies)
Discussion started by: whatisthis
3 Replies
3. Shell Programming and Scripting
I was wondering how can I do this
I have file myfile.txt
wc -l is: 5 000 000
I have to remove first 1 000 000 lines from header..
I tryed with tail -4000000 myfile.txt>newfile.txt
but it does not work...
any help?? (2 Replies)
Discussion started by: amon
2 Replies
4. Shell Programming and Scripting
Hello,
I would like to pipe two variables into awk, but I don't know how to do.
Each variable, "a" and "b", are in fact a list of data. They are not files.
So to get awk to work with it I am using:
echo $a | awk 'FNR==NR{print $1}FNR!=NR{print $4}'
The above works, but when I am... (5 Replies)
Discussion started by: jolecanard
5 Replies
5. Shell Programming and Scripting
Hi All,
My query seems to be silly but Iam unable to find where the exact problem lies.
I have a script to unzip set of files
here is the script
#!/bin/ksh
Count=`cat /home/gaddamja/Tempfile | wc -l`
while
do
Filename=`cat /home/gaddamja/Tempfile |tail -$Count | head -1`
cd... (7 Replies)
Discussion started by: jagadish_gaddam
7 Replies
6. Shell Programming and Scripting
How are pipes used inside a find -exec clause?
I want to traverse a directory tree and find all of the shell scripts, and then based on that I need to perfrom further processing. So I have something like
find . -name \* -exec "file {} \| grep 'script' > /dev/null" \; -ls
with -ls as a simple... (6 Replies)
Discussion started by: JerryHone
6 Replies
7. Shell Programming and Scripting
Hi,
In my home directory, there are so many files. i tried to get the lastly created file by following command.
file=`ls -lrt MXOfiles* | tail -1`
As there are so many files, it displays
"$ : 0403-027 The parameter list is too long."
Can someone tell me how can i get the recent file... (1 Reply)
Discussion started by: JSKOBS
1 Replies
8. Shell Programming and Scripting
Hi does anyone know how to create a file using the tail command? My book has this file I need to create and it says to use the tail command and that it is possible but I have no idea. Thanks. (4 Replies)
Discussion started by: drew211
4 Replies
9. UNIX for Beginners Questions & Answers
Hi Team,
Can anyone help me here:
I have to access server logs via putty and these logs file is a trailing file (continously updating) with ERROR and WARNINGS... I need to know if I can pull this trailing file to a local drive so that I can do some higlighting on some keywords through Notepad... (13 Replies)
Discussion started by: jitensetia
13 Replies
10. Shell Programming and Scripting
I'm trying to create a minimal, crude keylogger for X using only a shell script. I was quickly stumped: Why do these two commands entered in a terminal emulator produce output when I type...
$ xinput test 6 | grep press
$ xinput test 6 | awk '{print $3}'
...but this command produces no... (13 Replies)
Discussion started by: DevuanFan
13 Replies