Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Cat Start & End of File
Name: hismail Date: June 13, 2005 at 02:25:14 Pacific OS: Sco Openserver CPU/Ram: Dual processor/2 gig
Comment:
Hi Is there anyway of doing a "cat" of the start & end of a file & append it to another eg: __Start file______ 00:00 this is the start........ . . . 04:00 this is the end.. ---end of file------------- I need to put the start & end times of a log file to another file
Name: David Perry Date: June 13, 2005 at 04:12:52 Pacific
Reply:
head -1 > newfile tail -1 >> newfile
man head man tail
0
Response Number 2
Name: hismail Date: June 15, 2005 at 02:15:01 Pacific
Reply:
Hi
Thanks For your Help, I managed to get the out of the file but cannot get the home directory inside the contents of my file called HOME. any ideas??
LOG=`find . -name day0*.log -mtime +1 \ ` STARTFILE=`head -6 $LOG >/tmp/HOME` ENDFILE=`tail -l |grep Logfile $LOG>>/tmp/HOME` for dir in $HOME;do echo $HOME;done
it only echo the home directory to screen?
0
Response Number 3
Name: David Perry Date: June 17, 2005 at 12:42:05 Pacific
Reply:
Would you post a sample of your data file?
Where is $HOME being created?
0
Response Number 4
Name: hismail Date: June 19, 2005 at 23:41:49 Pacific
Reply:
My Previuos script does not give me the latest file created ie day*.log I tried this ,but it cannot find the first variable as it has to do a find inside the home directories. I am starting my script from /home;
Here is my script: #!/bin/ksh LOG=`ls -lt day*.log|grep "^-" |head -1 |awk '{print $NF}'` STARTFILE=`head -6 $LOG >/tmp/HOME` ENDFILE=`tail -l |grep Logfile $LOG>>/tmp/HOME` for f in $(find /home/sing* -type f -name $LOG);do cd $(dirname $f);$STARTFILE;$ENDFILE;cd - done
I get an error cannot find day*.log- How can I get my script to ignore $LOG & then use it again after the find.
Summary: GISmapper: I still learning sed, but this might work: sed '$a\ '"$(printf '\012')"' ' pipe your unzip command to the stub sed command above. The $a\ is sed's append to the end of file syntax. I'm ap...
Summary: Hawkeye: This should get you started: from the current directory, find all files within the past 24 hours named serial.txt; Use the xargs command to append the contents of each file to the end of fil...