Search Results

Search: Posts Made By: shoaibjameel123
3,823
Posted By Don Cragun
Hi shoaibjameel123, What happens when you apply...
Hi shoaibjameel123,
What happens when you apply your trick to the 1st input file still isn't clear. Did the code I suggested in post #4 do what you want, or did you want the updated 1st input file...
3,823
Posted By RudiC
This awk ' BEGIN {c = 1 ...
This
awk '
BEGIN {c = 1
}

!NF {next
}

/^DONE/ {for (i=2; i<c; i++) for (j=1; j<=MX; j++) print T[1,j], T[i,j] " > " (FILENAME...
3,823
Posted By RudiC
Try also awk ' !NF {next ...
Try also
awk '
!NF {next
}
/^DONE/ {for (i=1; i<=MX; i++) print T[i]
}
/^CONTINUE/ {n = 0
next
}
...
3,823
Posted By Don Cragun
I agree with RudiC that the leading CONTINUE line...
I agree with RudiC that the leading CONTINUE line makes no sense in your 1st sample input file. The following code silently ignores that line. Maybe something like:
#!/bin/bash
find . -name...
3,823
Posted By blastit.fr
Hi, See this sample running on one input...
Hi,

See this sample running on one input file :

$ cat cont1db.txt
size
waist-(on-half)
hip-(on-half)
inseam
CONTINUE
alt
14"
24-3/4"
34"
CONTINUE
axlt
15"
26-3/4"
34-1/2"
CONTINUE
1,547
Posted By RudiC
Add a closing square bracket to the first search...
Add a closing square bracket to the first search pattern:sed ':L;s/\(\[\[[^] ]*\) \([^]]*\]\)/\1-\2/;tL' file and try again.
1,398
Posted By RudiC
Try also awk 'NF==2{Q=$2} $2=Q' file a.txt...
Try also awk 'NF==2{Q=$2} $2=Q' file
a.txt computer
b.txt computer
c.txt computer
e.txt computer
And, overwrite the original file only when the command worked error free.
1,398
Posted By RavinderSingh13
Hello shoaibjameel123, Could you please try...
Hello shoaibjameel123,

Could you please try following and let me know if this helps you.

for file in *.txt
do
awk '{if($2==""){$2=Q};if($2){Q=$2};print}' $file > tmp_file
mv...
Forum: Programming 03-12-2016
1,644
Posted By Don Cragun
Note that the code: e.key = word; ...
Note that the code:
e.key = word;
e.data = (char *) file_name;
ep = hsearch ( e , ENTER ); //create a hash table
has word and file_name with identical addresses for each entry you add...
4,434
Posted By RudiC
How about awk ' {sub (" ", FS) ...
How about awk '
{sub (" ", FS)
$0=$0
T[$2]=(T[$2]?T[$2]"_":"") $1
}
END {for (t in T) print T[t], t
}
' FS="\001" file
8.txt apple is a fruit...
4,434
Posted By RavinderSingh13
Hello shoaibjameel123, Could you please try...
Hello shoaibjameel123,

Could you please try following and let me know if this helps you.

awk 'FNR==NR{A=$1;$1="";array[$0]=array[$0]?array[$0] "_" A:A;next} {$1="";B=$0} (B in...
4,455
Posted By RudiC
Paralleling process won't help but increase...
Paralleling process won't help but increase memory congestion as every process will allocate own memory for the same operations.

Don't cat the big_file but have sed read the file directly - that...
8,836
Posted By Don Cragun
The REs required to match two words of context...
The REs required to match two words of context before and after a specified word using grep are much more complex than the exact word matches I'm using in the awk field in array tests. So I was...
8,836
Posted By Don Cragun
I had a much more complicated awk script that...
I had a much more complicated awk script that ignores line boundaries when looking for the two words before and after words found in words_file.txt, but this simple script seems to do what you want...
8,836
Posted By drl
Hi. I'm not going to post everything because...
Hi.

I'm not going to post everything because I'm still thinking about it, but this version of the grep pattern seems to produce the expected output:
grep -owP...
8,836
Posted By bakunin
Wouldn't it be the easiest to put the...
Wouldn't it be the easiest to put the big_file.txt to some RAMDisk and then read from there? How to make a RAMDisk is depending on your system, but i'm sure there is one. It might require areboot,...
8,836
Posted By RudiC
Please post small but meaningful samples of your...
Please post small but meaningful samples of your two files. And, use code not icode tags.

---------- Post updated at 13:02 ---------- Previous update was at 11:32 ----------

Would this help as...
13,856
Posted By Aia
Perhaps grep -owP...
Perhaps
grep -owP '(?:\w+\s){0,2}words(?:\s\w+){0,2}' sample.txt
13,856
Posted By RavinderSingh13
Hello shoaibjameel123, Following may help...
Hello shoaibjameel123,

Following may help you in same.

awk '{for(i=1;i<=NF;i++){if($i == "words"){print $(i-2) OFS $(i-1) OFS $i OFS $(i+1) OFS $(i+2)}}}' Input_file
Output will be as...
5,897
Posted By Chubler_XL
You can also use sed for the task: sed -e...
You can also use sed for the task:

sed -e 's/^-//' -e 's/-$//' filename
1,159
Posted By Don Cragun
You were very close, just change: awk...
You were very close, just change:
awk '/\.U/{c=2}c&&c--' fileto:
awk '/\.[UW]/{c=2}c&&c--' file
1,930
Posted By Yoda
Or use sub function: awk...
Or use sub function:
awk '{sub(1,"+1",$1);sub(0,"-1",$1)}1' file
1,930
Posted By PikK45
awk '{ if( $1 == 1) $1 = "+1"; else if ($1 == 0)...
awk '{ if( $1 == 1) $1 = "+1"; else if ($1 == 0) $1= "-1"; print;}' inputfile

If you have the first column to be 1 and 0 only, then use awk '{ if( $1 == 1) $1 = "+1"; else $1= "-1"; print;}'...
1,157
Posted By Akshay Hegde
Try : $ cat file 14998 16 0 11680 3165...
Try :
$ cat file
14998
16 0 11680 3165 15343 8553 9925 3875 820 6430 14226 13261 11355 15428 9140 16184 7934 217
67 0 3165 11680 3884 12846 15343 5982 6486 9925 14226 11355 7933 17900 16131 12057...
7,096
Posted By RudiC
I don't think you can do this with grep. You may...
I don't think you can do this with grep. You may want to try this awk that works with the sample you posted. For different input it may need to be modified.awk '/News\/U.S./ {CNT++; next} CNT==3...
Showing results 1 to 25 of 220

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