473,657 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EPISOD E_1;
DB2ADMIN.EPISOD E_2;
DB2ADMIN.EPISOD E_3;
DB2ADMIN.EPISOD E_4;
DB2ADMIN.EPISOD E_5;
DB2ADMIN.EPISOD E_6;
DB2ADMIN.EPISOD E_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.EPISOD E_%' 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 3727
On Jun 22, 11:32 am, "Okonita via DBMonster.com" <u36825@uwewrot e:
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.EPISOD E_1;
DB2ADMIN.EPISOD E_2;
DB2ADMIN.EPISOD E_3;
DB2ADMIN.EPISOD E_4;
DB2ADMIN.EPISOD E_5;
DB2ADMIN.EPISOD E_6;
DB2ADMIN.EPISOD E_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.EPISOD E_%' 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.EPISOD E_ < infile outfile

should do the trick
/Lennart

Thanks

--
Message posted viahttp://www.dbmonster.c om
Jun 27 '08 #2
On Jun 22, 12:15 pm, Lennart <Erik.Lennart.J ons...@gmail.co mwrote:
On Jun 22, 11:32 am, "Okonita via DBMonster.com" <u36825@uwewrot e:
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.EPISOD E_1;
DB2ADMIN.EPISOD E_2;
DB2ADMIN.EPISOD E_3;
DB2ADMIN.EPISOD E_4;
DB2ADMIN.EPISOD E_5;
DB2ADMIN.EPISOD E_6;
DB2ADMIN.EPISOD E_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.EPISOD E_%' 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.EPISOD E_ < infile outfile

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

sed -e "/DB2ADMIN.EPISOD E_/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.EPISO DE_%' 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.EPISOD E_ < infile outfile

should do the trick

/Lennart
>Thanks

--
Message posted viahttp://www.dbmonster.c om
--
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
2997
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 lately I've been wanting to do more stuff with user accounts, and had been eying MySQL for over a year. Finally I've decided to start off small by converting the forum's account system to a MySQL database (and convert the rest later after I'm...
1
2972
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 some flat-files that stored the signups, prior to this new form. Email addresses weren't checked, so there are a lot of records that have the same email address. Once I import these into the table, how would I go about putting together a SQL...
0
393
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 is that, I cannot put data into a compressed folder in C++, in spite of the fact that all operations succeed. Note: all this have to work under XP and above, because of integrated
2
2135
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 attempt to.... In the script version I repeatedly get OSError exceptions stating permission denied when trying to delete or rename My exception print out... Files system said no: Permission denied:
4
2374
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 my own tool (http://openswarm.sourceforge.net). I already started restructuring my code to separate the actual command implementations from the command-line scripts (which is optparser-based now) and have some ideas how to proceed. But probably...
21
3012
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 take it as -winpath "c:\temp\" and csh will take it literally (with the double-slashes). Is there a way for me to know what shell is currently running my
5
5078
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 passes these as arguments to a configurable shell script or OS command. I would like for the output generated from the shell script/command shall be displayed in a new javascript window once the form is submitted. Optimally a user should not...
3
3944
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 am fairly happy using IDLE, the debugger is unintuitive to me and I wanted a project manager and a better variable/ class browser and also the potential to edit/run other languages such as R and Tex/Latex. Windows and LINUX compatibility is...
1
47445
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 on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
8403
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.