Search Results

Search: Posts Made By: mad man
2,338
Posted By wbport
Let's try this for a sed command file. You will...
Let's try this for a sed command file. You will need to specify -n before the name of your sed command file.
/-->/ { N
N
s/ *//
s/--//
s/>//
s/TP...
2,338
Posted By RudiC
This is as far as I can get:awk ' ...
This is as far as I can get:awk '
{getline X
getline Y
$0 = $0 FS X FS Y
sub (/^--> TP *ID: /, _)
FS = "|"
gsub (/ +/, FS)

$1 =...
1,519
Posted By bakunin
Is the format of the lines fixed? (That is, will...
Is the format of the lines fixed? (That is, will "{1:F" and "{2:I" always appear at a certain column?) If so, you won't even need to search for it.

First, you won't need grep because sed can do...
1,519
Posted By Aia
perl -nle '/\{2:I(\d{3})/ and print $1'...
perl -nle '/\{2:I(\d{3})/ and print $1' mad_man.example
1,519
Posted By RudiC
Try also awk 'match ($0, /{1:F.*2:I.../) {print...
Try also
awk 'match ($0, /{1:F.*2:I.../) {print substr ($0, RSTART+RLENGTH-3,3)}' file
103
103
103
1,519
Posted By RavinderSingh13
Hello mad_man, Could you please try...
Hello mad_man,

Could you please try following and let me know if this helps you.
Solution 1st:

awk '/1:F.*2:I/{sub(/.*2:I/,"");print substr($0,1,3)}' Input_file

Solution 2nd:

awk...
3,271
Posted By Don Cragun
The real question is not what the region is when...
The real question is not what the region is when the code works or fails, but to what do the expansions of the three shell variables: com_dir, dup_file_name_chk, and save_dir expand when the code...
Forum: Tips and Tutorials 08-30-2007
755,472
Posted By Perderabo
Using perl to display the file timestamps
The ls program will display mtime if you use "ls -l". And you can get atime or ctime with "ls -lu" or "ls -lc". But ls uses a strange format. It displays the month and day in all cases. If the...
2,257
Posted By Aia
It is based on the premise that the following...
It is based on the premise that the following structure is true:
A line starting with a digit or more which we want to capture, followed by another line where we would like to split the line into...
2,257
Posted By RudiC
Howsoever, would this do: awk '$NF == "DISK" {$NF...
Howsoever, would this do: awk '$NF == "DISK" {$NF = ""; X = $0; getline; $1 = ""; $0 = X $0; print}' file
144185 qqr8ot6l_1_1
144186 ukr8pf2e_1_1
144187 ter8p9gc_1_1
144188 4er8qb84_1_1
4,189
Posted By RudiC
What be the actual lengths of your lines?
What be the actual lengths of your lines?
4,189
Posted By RavinderSingh13
Hello mad man, Not sure but the Input_file...
Hello mad man,

Not sure but the Input_file which you have shown doesn't have any line whose length is more than 1330, so if you are using same Input_file I don't think so it will show any output....
4,189
Posted By RudiC
You're talking of <newline> chars, not <carriage...
You're talking of <newline> chars, not <carriage return>?

Try awk '{while (length < 1330 && getline s>0) $0=$0 " " s}1' file
5,847
Posted By Don Cragun
I would be happy to help you! So, exactly...
I would be happy to help you!

So, exactly what pathname should this single output file have?

What good is this file going to be given that the script that will be reading this file can only...
5,847
Posted By Don Cragun
I sincerely apologize. In each case, the output...
I sincerely apologize. In each case, the output file you got had a filename derived from the 2nd field (i.e., the data between the 1st and 2nd tildes which seems to be a constant for the...
Forum: Solaris 12-07-2006
123,134
Posted By Ygor
Try...nawk...
Try...nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=2 a=4 s="string" file1...where "b" and "a" are the number of lines to print before and after string "s".
...
5,847
Posted By Don Cragun
Realize that I have been up all night trying to...
Realize that I have been up all night trying to help you (and it is now almost 6AM where I am), so I may not be thinking clearly. But, could you please explain why you chose to change the code I...
5,847
Posted By Scrutinizer
Try this adaptation of RudiC's suggestion and...
Try this adaptation of RudiC's suggestion and Don's adaption for proper shell quoting on AIX:
sed -n "
/~$transnum~/ {
H
g
}
/~$transnum~/,/EOT/p
h
" file

---


Not so much 2047 bytes,...
5,847
Posted By RudiC
I don't think I can do better than what I have...
I don't think I can do better than what I have already offered. With an input file of three similar records with different transnums, it extracts the desired one:
transnum=ABC160120XYZ0983920
sed...
5,847
Posted By RudiC
That sed works with your sample data as...
That sed works with your sample data as specified, it extracts exactly that record from a set of different records.
The data structure is NOT what you posted earlier. E.g. the transnum is not the...
5,847
Posted By RudiC
The sed script as provided was tested and worked...
The sed script as provided was tested and worked for me, as is on Linux, with Don Cragun's semicolon inserted on FreeBSD.
So, how about
- supplying meaningful samples of input data (as requested...
5,847
Posted By RudiC
How about sed -n '/~transnum~/ {H;g};...
How about sed -n '/~transnum~/ {H;g}; /~transnum~/,/EOT/p;h' file
5,847
Posted By Aia
Extracting the first transaction only. perl -ne...
Extracting the first transaction only.
perl -ne 'print if /^##transaction\b/ .. /EOT$/; last if /EOT$/' mad_man.example
##transaction, , , ,blah, blah
%%blah~trannum~blah~blah~blah
0000content01...
5,847
Posted By Don Cragun
It looks like Scrutinzer's suggestion should work...
It looks like Scrutinzer's suggestion should work just fine as long as:

trannum does not contain any characters that are special in an ERE, and
the number of bytes in a single transaction (from...
5,847
Posted By Scrutinizer
Try something like: awk '{p=p $0 RS}...
Try something like:
awk '{p=p $0 RS} /EOT/{if(p~s)printf "%s",p; p=x}' s='~trannum~' file
Showing results 1 to 25 of 27

 
All times are GMT -4. The time now is 02:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy