---------- Post updated at 05:24 PM ---------- Previous update was at 03:38 PM ----------
HI Birei,
I edited it little bit, the script i mean.. i need to read the files from a particular directory and edit the way i told u..
grep is the directory. It should edit each of the files in this directory. Is the script correct. But its not editing the files at all. Could you just check?
Code:
#!/usr/bin/perl -w
use warnings;
use strict;
my @files;
my $file;
@files = </tmp/grep/*>;
foreach $file (@files) {
my @lines;
my @prev_line;
printf $file;
open (FILE,"+>>$file") or die "Can't open $file: $!\n";
@lines= <FILE>;
while ( @lines) {
chomp;
if ( /\A\*\*/ .. eof ) {
next if m/\A\s*\Z/;
if ( m/¦/ ) {
if ( @prev_line ) {
printf qq[%s\n], pop @prev_line;
}
push @prev_line, $_;
next;
}
printf qq[%s\n], (pop @prev_line) . $_;
next;
}
printf qq[%s\n], $_;
}
print $file . "Processed\n";
}
i was using this command from grep dir.
Code:
perl -i ../script2.pl
Last edited by Scrutinizer; 04-16-2012 at 08:57 AM..
Reason: code tags
Gurus,
I am struggling with a issue and thought I could use some of your expertise.
Need Help with this
I have a flat file that has millions of records
24|john|account ~ info |56|
25|kuo|account ~ journal |58|
27|kim|account ~ journal |59|
28|San|account ~
journal |60|... (3 Replies)
Hi
I have two lines of data formatted as displayed below
shop, price, remark, date
a,#N/A,order to -fd, 20091011
and would like it to be
shop:a
price:#N/A
remark:order to -fd
date:20091011
How can I do it?
Many thanks (2 Replies)
Hi,
I'm not a expert in shell programming, so i've come here to take help from u gurus.
I'm trying to tailor a csv file that i got to make it work for the LOAD FROM command.
I've a datatable csv of the below format -
--in file format
xx,xx,xx ,xx , , , , ,,xx,
xxxx,, ,, xxx,... (11 Replies)
I have a plain test file with a delimeter ''. In this file some lines are broken into two. The first part of these broken line will have 6 columns and the second part will have 4. These broken lines will be consicutive.
I want to join the two consicutive lines which are having 6 fields and 4... (8 Replies)
Hi,
I have a 100 byte length fixed width file . In that three rows are broken and went off to next line. How can I identify the broken lines?
E.g.
ABCD1234MNRD4321
abcd1234mnrd
4321
As you can see in my example my second row with small case alphabets is broken... (5 Replies)
Hello
I have a file with
CAR 23
COLOR 12
CAR 44
COLOR 12
CAR 55
COLOR 20
SIZE BIG
CAR 56
CAR 57
COLOR 11
How can merge the CAR and the COLOR + SIZE (if there are COLOR,SIZE)
CAR 23 COLOR 12
CAR 44 COLOR 12
CAR 55 COLOR 20 SIZE BIG
CAR 56
CAR 57 COLOR 11
Every line begin in... (4 Replies)
Hi,
I have a huge file with sql broken statements like:
PP3697HB @@@@0
<<<<<<Record has been deleted as per PP3697HB>>>>>>
FROM sys.xtab_ref rc,sys.xtab_sys f,sys.domp ur WHE
RE rc.milf = ur.milf AND rc.molf = f.molf AND ur.dept = 'SWIT'AND ur
.department = 'IND' AND share = '2' AND... (4 Replies)
Hello
I have an input as below
this is test
we
are(
)
one
end of description
I am looking for output
this is test
we are () one
end of description (2 Replies)
Hi - I have req to join broken lines and remove empty lines but should NOT be in one line. It has to be as is line by line. The challenge here is there is no end of line/start of line char.
thanks in advance
Source:-
2003-04-34024|04-10-2003|Claims|Claim|01-13-2003|Air Bag:Driver;... (7 Replies)
Discussion started by: Jackceasar123
7 Replies
LEARN ABOUT LINUX
zegrep
ZGREP(1) General Commands Manual ZGREP(1)NAME
zgrep - search possibly compressed files for a regular expression
SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename...
DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code:
(-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the
standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep.
If the GREP environment variable is set, zgrep uses it as the grep program to be invoked.
EXIT CODE
2 - An option that is not supported was specified.
AUTHOR
Charles Levert (charles@comm.polymtl.ca)
SEE ALSO grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1)ZGREP(1)