Search Results

Search: Posts Made By: wahi80
1,932
Posted By RudiC
Not as sophisticated as bakunin's proposal (esp....
Not as sophisticated as bakunin's proposal (esp. the date detection regex), but you could try also
tac file | sed -n '/^2018/!{G; h; b}; G; s/\n//g; p; s/.*//; h' | tac
It starts from the end,...
2,138
Posted By RudiC
Either of the two above proposals almost fulfill...
Either of the two above proposals almost fulfill the needs of the OP. Stealing from both, a - hopefully - complete solution was composed:
awk -F, '
NR == FNR {S[NR] = $0
...
2,138
Posted By vgersh99
something along these lines: wahi.awk: ...
something along these lines:
wahi.awk:

BEGIN {
FS=OFS=","
if (!repL) replL="2,66,3,Sky,4,Pink"
replN=split(replL, replA, FS)
}
{
found=1
for(i=1;i<replN-1; i=i+2)
if...
2,138
Posted By Yoda
You can create another file as a reference for...
You can create another file as a reference for search and replace and use it:-
$ cat ref.txt
2,66,4,Pink
1,B,3,Tennis
awk -F, '
NR == FNR {
S[$1] = $2 FS $3 FS $4
...
2,382
Posted By RudiC
T[$1"."$2]=$3This statement first concatenates...
T[$1"."$2]=$3This statement first concatenates the first and second field with a dot separator, then uses this string as an index for array T and assigns the third field's value to it. Reading all...
2,382
Posted By Chubler_XL
Not sure about the contents of the part-m-00000...
Not sure about the contents of the part-m-00000 file but this should do the trick:

awk -F "[ |]*" '
FNR==NR{T[$1"."$2]=$3; next}
FNR>1{
printf $1 "|" $2 "|"
flds=split($2, F, ",")
...
6,452
Posted By MadeInGermany
Run a controll shell that can write an error...
Run a controll shell that can write an error file:
errfile="errorfile"
rm "$errfile"
while read LINE && [ ! -f "$errfile" ]
do
...
while [ ! -f "$errfile" ]
do
...
(stuff "$LINE" ||...
1,987
Posted By RudiC
That might fail on 66XYZ. How about sed 's/...
That might fail on 66XYZ. How about sed 's/ \([0-9]*|\)/\1/g' file
4,841
Posted By sea
I love arrays: #!/bin/bash C=1 declare -A ...
I love arrays:
#!/bin/bash
C=1
declare -A BALL

while read color;do
BALL[${color,,}]=$C
C=$(( $C + 1 ))
done<"${0/sh/txt}"

echo "Ball $1 is worth ${BALL[${1,,}]}"

Have a good week :)...
4,841
Posted By RudiC
With a recent bash, try[[ "$(tail -${LEFT_OVR}...
With a recent bash, try[[ "$(tail -${LEFT_OVR} color.txt | tr '\n' ' ' )" =~ "$color" ]] && echo good || echo bad
5,456
Posted By Don Cragun
Just to be perfectly clear, the command...
Just to be perfectly clear, the command Scrutinizer was suggesting was:
find /app/*/upd -type f -name "*ONE*"
The warning message you got from find would be more likely from a command like:
find...
5,456
Posted By Scrutinizer
That just warns there should no slashes used with...
That just warns there should no slashes used with -name, because file names never contains slashes..
1,660
Posted By MadeInGermany
This one works with your example: sed 's/...
This one works with your example:
sed 's/ \([0-9][0-9]*\)\./\1/g' file---------- Post updated at 05:44 PM ---------- Previous update was at 05:36 PM ----------

This one works according to your...
3,806
Posted By xbin
Try the following-> sed '/.*_id...
Try the following->

sed '/.*_id .*/s/double/string/' FILE
2,081
Posted By DGPickett
Even with ERE, you need to run it twice, perhaps...
Even with ERE, you need to run it twice, perhaps conditionally if the first hits, as you used both start and end field '|'. Otherwise, you miss the following adjacent fields on a line like:...
2,081
Posted By agent.kgb
sed -e 's/\([0-9]\).|/\1|/g' -e...
sed -e 's/\([0-9]\).|/\1|/g' -e 's/\([0-9]\).$/\1/'
1,697
Posted By Walter Misar
grep "$A"'\>' *should do the trick: double quotes...
grep "$A"'\>' *should do the trick: double quotes to allow expanding of $A, single ones for the rest.

edit: of course just using double quotes will do too:

grep "$A\>" *
15,693
Posted By RavinderSingh13
Hello Wahi80, Following may help you in...
Hello Wahi80,

Following may help you in same.


awk -vs1="'" '{S=S?S OFS s1 $0 s1:s1 $0 s1} END{print S}' OFS=, Input_file


Output will be as follows.

...
1,615
Posted By Scrutinizer
Another approach awk '{gsub(/[^,]+/, "t1.&=s1.&",...
Another approach awk '{gsub(/[^,]+/, "t1.&=s1.&", $2); gsub(/,/," AND ", $2)} NR>1' FS=' *[|] *' OFS=\| file
1,615
Posted By Chubler_XL
You already use awk to get your KEYCNT so why not...
You already use awk to get your KEYCNT so why not use awk to do all the processing:

awk -F "[ |]*" '
NR>1{
printf $1 " | "
flds=split($2, F, ",")
for(i=0;i<flds;i++)
printf...
2,447
Posted By pilnet101
sed -e 's/ *[^ ]*,/,/g' file
sed -e 's/ *[^ ]*,/,/g' file
Showing results 1 to 21 of 21

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