Sponsored Content
Top Forums Shell Programming and Scripting Need a script or one-liner to purge lines from a file. Post 302461898 by kooshi on Tuesday 12th of October 2010 04:39:19 PM
Old 10-12-2010
I've only used Perl for scripting, so I'll give you some advice for Perl.

Read rules.txt and read each line.
If the line has any of those keywords in defaultRules, then do nothing.
Else, put that line into an output file rules.out

Code:
open(INPUTFILE, "<rules.txt");
open(OUTPUTFILE, ">rules.out");

while (<INPUTFILE>) {
    my $line = $_;
    if ($line =~ m/IPSEC_AH/i || $line =~ m/IKE_UDP/i || $line =~ m/IPMP_TEST_IFACE2/i) {
             print OUTPUTFILE "$line";
    }
}

close(INPUTFILE);
close(OUTPUTFILE);

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script for purge

Hi , I want to purge 7 days older data from a list of data sorted on date in a log file... Can anyone provide me with the shell script for the same.. Thanks, Jaz (1 Reply)
Discussion started by: JP003
1 Replies

2. Shell Programming and Scripting

shell script for archive purge

I am writing a shell script for Archive Purge for the table having rows < 1 year. The shell script has to extract the rows from the table and write those extracted rows to a text file. Then from the text file, each rows will be read and deleted by means of delete query one by one. The fields will... (5 Replies)
Discussion started by: regnumber
5 Replies

3. Shell Programming and Scripting

script to archive and purge

Hi, I am writing a shell script for archive data from a table. The design is as follows. Step 1: Execute the select query and extract the data into a text file. Step 2: The primary key for this table is TRACKING_NUM, TRACKING_NUM_SUFFIX, TIMESTAMP_UPDATED. So These three fields will be read... (1 Reply)
Discussion started by: kmanivan82
1 Replies

4. Shell Programming and Scripting

Sed one-liner to print specific lines?

I need to print specific lines from a file, say 2-5, 8, 12-15, 17, 19, 21-27. How do I achieve this? (2 Replies)
Discussion started by: Ilja
2 Replies

5. Shell Programming and Scripting

Shell script to check the files hourly and purge

I'm new to shell scripting... i have been given a task.. can any one help in this regard.... 1) Check hourly for files in <destination-path><destination-file-template><destination-file-suffix> for files older than <destination-file-retention> days and purge. It should then check... (1 Reply)
Discussion started by: satishpabba
1 Replies

6. UNIX for Advanced & Expert Users

Purge MAil file

Hi, merry christmas. on AIX 6.1, the file /var/spool/mail/user, should/can be purged manually ? Any commande line to purge it ? Thanks. (2 Replies)
Discussion started by: big123456
2 Replies

7. Shell Programming and Scripting

Search & Replace regex Perl one liner to AWK one liner

Thanks for giving your time and effort to answer questions and helping newbies like me understand awk. I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk. Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Discussion started by: verge
9 Replies

8. Shell Programming and Scripting

To create a script and schedule which purge 30 days old files

Hi Friends, Very new in Unix and i got a requirement like writing a script and schedule it, so that it removes 30 days old files from all the log locations of a unix box. Suppose i have a unix server ltbamdev1 and in this server i have a mount point opt/bam. In this mount point i have 3... (1 Reply)
Discussion started by: duos
1 Replies

9. Shell Programming and Scripting

Perl one liner to wrap comment lines

Greetings fellow scripters. I find myself editing multiple files, sometimes with the same bits of information. My bash script, a changelog, and a plist file (OS X). Once I realized this, I thought why not script part of this process (and so it begins). In any case, I've solved several of the... (1 Reply)
Discussion started by: reid
1 Replies

10. Shell Programming and Scripting

sed one liner to Delete blank lines - Help required

Hi, cat test.txt BlankLine BlankLine BlankLine BlankLine ello hi helo BlankLine BlankLine heylo BlankLine BlankLine BlankLine done BlankLine BlankLine BlankLine (1 Reply)
Discussion started by: TomG
1 Replies
XRACER-TOOLS(1) 					      General Commands Manual						   XRACER-TOOLS(1)

NAME
xracer-mktrack -- XRacer track generator SYNOPSIS
xracer-mktrack --steps STEPS [--outputc OUTPUTFILE] [--verbose] --tubefile TUBEFILE [INPUTFILE] DESCRIPTION
This manual page documents briefly the xracer-mktrack command. This manual page was written for the Debian distribution because the original program does not have a manual page. xracer-mktrack is a perl script that takes a Blender VideoScape file INPUTFILE and a tube file generated by mktube TUBEFILE and optionally generates a C source file OUTPUTFILE that contains code suitable to be used as a track in the game XRacer. OPTIONS
--steps STEPS the number of vertices in each segment --outputc OUTPUTFILE the C file to write --verbose verbose output --tubefile TUBEFILE the tube file generated by mktube prog SEE ALSO
xracer (6), XRacer::BVRML (3pm), xracer-mktube (1) AUTHOR
This manual page was written by Ying-Chun Liu (PaulLiu) <grandpaul@gmail.com> for the Debian system (but may be used by others). Permis- sion is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later ver- sion published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. XRACER-TOOLS(1)
All times are GMT -4. The time now is 08:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy