Computing.Net > Forums > Unix > Seperate files - Str Match/Not matc

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.

Seperate files - Str Match/Not matc

Reply to Message Icon

Name: Nish
Date: October 9, 2002 at 04:19:19 Pacific
OS: Solaris
CPU/Ram: 256
Comment:

Hi,
I have a large file and some rows contain 00:00:00:00 (duration zero) string set.I need to seperate those lines does and does not contain the above string set and store them in two different files.
I'm using ksh.
Appreciate your Help Pls.
Nish.



Sponsored Link
Ads by Google

Response Number 1
Name: jimbo
Date: October 9, 2002 at 05:26:03 Pacific
Reply:

Try this:

egrep "00:00:00:00:" DATA > file_with.txt
egrep -v "00:00:00:00:" DATA > file_without.txt

-jim


0

Response Number 2
Name: jimbo
Date: October 9, 2002 at 12:32:50 Pacific
Reply:

Here is a ksh script:

#! /bin/ksh
[[ -f FILE1 ]] && rm FILE1
[[ -f FILE2 ]] && rm FILE2
while read line ; do
case "$line" in
*00:00:00:00*) print "${line}" >> FILE1 ;;
*) print "${line}" >> FILE2 ;;
esac
done < YOUR_FILE

-jim


0

Response Number 3
Name: jimbo
Date: October 9, 2002 at 12:36:52 Pacific
Reply:

Here is the above post, formatted with coder.exe:

#! /bin/sh

while read line ; do

case "$line" in
*00:00:00:00*) echo "${line}" >> temp1 ;;
*) echo "${line}" >> temp2 ;;
esac

done < data.tmp


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


unix scripts Prb with empty columns



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Seperate files - Str Match/Not matc

Extracting lines from a file www.computing.net/answers/unix/extracting-lines-from-a-file/5403.html

passing files as argument www.computing.net/answers/unix/passing-files-as-argument/7161.html

deleting files older than 2 days www.computing.net/answers/unix/deleting-files-older-than-2-days/4394.html