473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How can I use shell script to remove specific records from a flat file?

Hi all,
Working on a little shell script to remove specific records from a flat file.
I have scanned a one or two script books and googled for answers but have no
success. Can someone show me how I can do this. For example, how can I remove
the something like the following records from among 200 other records:
DB2ADMIN.EPISODE_1;
DB2ADMIN.EPISODE_2;
DB2ADMIN.EPISODE_3;
DB2ADMIN.EPISODE_4;
DB2ADMIN.EPISODE_5;
DB2ADMIN.EPISODE_6;
DB2ADMIN.EPISODE_7;

You see, they are not duplicates, so uniq will not do the job. Is there
another keyword that can remove something lke these given a string such as '
DB2ADMIN.EPISODE_%' in a shell script?
I'll truly appreciate any help I can get on this...

Thanks

--
Message posted via http://www.dbmonster.com

Jun 27 '08 #1
3 3710
On Jun 22, 11:32 am, "Okonita via DBMonster.com" <u36825@uwewrote:
Hi all,
Working on a little shell script to remove specific records from a flat file.
I have scanned a one or two script books and googled for answers but have no
success. Can someone show me how I can do this. For example, how can I remove
the something like the following records from among 200 other records:
DB2ADMIN.EPISODE_1;
DB2ADMIN.EPISODE_2;
DB2ADMIN.EPISODE_3;
DB2ADMIN.EPISODE_4;
DB2ADMIN.EPISODE_5;
DB2ADMIN.EPISODE_6;
DB2ADMIN.EPISODE_7;

You see, they are not duplicates, so uniq will not do the job. Is there
another keyword that can remove something lke these given a string such as '
DB2ADMIN.EPISODE_%' in a shell script?
I'll truly appreciate any help I can get on this...
grep -v is probably what you are looking for. Something like:

grep -v DB2ADMIN.EPISODE_ < infile outfile

should do the trick
/Lennart

Thanks

--
Message posted viahttp://www.dbmonster.com
Jun 27 '08 #2
On Jun 22, 12:15 pm, Lennart <Erik.Lennart.Jons...@gmail.comwrote:
On Jun 22, 11:32 am, "Okonita via DBMonster.com" <u36825@uwewrote:
Hi all,
Working on a little shell script to remove specific records from a flat file.
I have scanned a one or two script books and googled for answers but have no
success. Can someone show me how I can do this. For example, how can I remove
the something like the following records from among 200 other records:
DB2ADMIN.EPISODE_1;
DB2ADMIN.EPISODE_2;
DB2ADMIN.EPISODE_3;
DB2ADMIN.EPISODE_4;
DB2ADMIN.EPISODE_5;
DB2ADMIN.EPISODE_6;
DB2ADMIN.EPISODE_7;
You see, they are not duplicates, so uniq will not do the job. Is there
another keyword that can remove something lke these given a string such as '
DB2ADMIN.EPISODE_%' in a shell script?
I'll truly appreciate any help I can get on this...

grep -v is probably what you are looking for. Something like:

grep -v DB2ADMIN.EPISODE_ < infile outfile

should do the trick
Another option is of course to use sed:

sed -e "/DB2ADMIN.EPISODE_/d"

A third to use awk/perl/python/ruby/...
Jun 27 '08 #3
Hello again Lennart,

Thanks for chipping in...I think I have it now


Lennart wrote:
>Hi all,
Working on a little shell script to remove specific records from a flat file.
[quoted text clipped - 13 lines]
>DB2ADMIN.EPISODE_%' in a shell script?
I'll truly appreciate any help I can get on this...

grep -v is probably what you are looking for. Something like:

grep -v DB2ADMIN.EPISODE_ < infile outfile

should do the trick

/Lennart
>Thanks

--
Message posted viahttp://www.dbmonster.com
--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....m-db2/200806/1

Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Daniel Tonks | last post by:
First, please excuse the fact that I'm a complete MySQL newbie. My site used forum software that I wrote myself (in Perl) which, up until now, has used flat files. This worked fine, however...
1
by: JStrummer | last post by:
I just put together a PHP mailing list sign-up page that posts to a mySQL DB. The PHP script prevents INSERTs when the email address is already located in the database. Problem: I need to import...
0
by: Vladimir Nesterovsky | last post by:
Hello, I'm having a trouble with a Shell.Folder object when I'm trying to use it from a C++ application, but at the same time, the same object works fine from within html script. The effect...
2
by: jdlists | last post by:
I'm running python on windows and have a program that watches a directory and acts on files as they come into the directory. After processing is complete, i delete the file, or in this case...
4
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
21
by: Tom Gur | last post by:
Hi, It's seems that csh and tcsh acts a bit different when handling special characters in quotes. i.e: if i'll supply my program with the following arguments: -winpath "c:\\temp\\" tcsh will...
5
by: inetquestion | last post by:
I am looking for a web interface for shell commands or shell scripts. Does anyone know of any exexisting php scripts which would solve this requirement? PHP form accepts input from a user, then...
3
by: mmm | last post by:
I am looking for advice on Python Editors and IDEs I have read other posts and threads on the subject and my two questions at this time are mainly about the IDLE-like F5-run facilities. While I...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.