Search Results

Search: Posts Made By: vegasluxor
986
Posted By Akshay Hegde
You passed variable successfully, try like this ...
You passed variable successfully, try like this

awk -v var1="abc123" '$0 ~ var1{x=NR+1}(NR<=x){print}' sftp_log_20150317.log
4,844
Posted By anbu23
awk -F"," ' ! $1 ' file Or sed -n "/^...
awk -F"," ' ! $1 ' file

Or

sed -n "/^ *,/p" file
4,878
Posted By Akshay Hegde
Did you try perl script I had given ? can...
Did you try perl script I had given ?

can you post the output of od -c f2
4,878
Posted By Akshay Hegde
I receive this o/p, run dos2unix before inputing...
I receive this o/p, run dos2unix before inputing files
[akshay@nio tmp]$ awk 'FNR==NR{a[$1];next}!($3+0 in a)' f1 FS=',' f2
2,2,333


---------- Post updated at 03:59 PM ---------- Previous...
4,878
Posted By Akshay Hegde
It can be simplified by just adding zero, no...
It can be simplified by just adding zero, no need of match and gsub

[akshay@nio tmp]$ cat f1
1
2
3

[akshay@nio tmp]$ cat f2
a,0001
b,02
c,000
d,01
e,2
f,0005

[akshay@nio tmp]$ awk...
4,878
Posted By RavinderSingh13
Hi vegasluxor, Following may help in same. ...
Hi vegasluxor,

Following may help in same.


awk -F, 'FNR==NR{A[$1]=$1;next} {match($2,/.*0[1-9]/);V=$2;gsub(/0/,X,V);gsub(/^$/,0,V);} !(V in A) {print $0}' file1 file2


Output will be...
1,855
Posted By Scrutinizer
Not sure if it will make much of a difference,...
Not sure if it will make much of a difference, but something like this:
find . -type f -name '*.txt' -exec grep -F 99023 {} + > myresult.text

You can use grep -Fh is you want to omit the file...
4,606
Posted By pamu
OR $ awk -F , '!$4{$4="BIKE"}1' OFS=","...
OR

$ awk -F , '!$4{$4="BIKE"}1' OFS="," file

1,abc,55,CAR
3,bb,dd,CAR
5,ddd,tttt,BIKE
8,ee,55,BIKE
4,606
Posted By RavinderSingh13
Hello, Following may also help in same. ...
Hello,

Following may also help in same.


awk 'NR==3 || NR==4 {$(NF+1)="BIKE"} 1' OFS="," file_name


Output will be as follows.


1,abc,55,CAR
3,bb,dd,CAR
5,ddd,tttt,BIKE...
4,606
Posted By CarloM
-F "," - use comma as the field separator $4...
-F "," - use comma as the field separator
$4 != "CAR" {$4 = "BIKE"} - if field 4 is not 'CAR' then set field 4 to BIKE (note that this will replace anything that isn't CAR, not just empty ones)
...
4,606
Posted By SriniShoo
awk -F "," '$4 != "CAR" {$4 = "BIKE"}1' OFS=","...
awk -F "," '$4 != "CAR" {$4 = "BIKE"}1' OFS="," file
1,721
Posted By RudiC
This may be even better, as it makes the leading...
This may be even better, as it makes the leading comma check compulsory for both fields:grep -E "^(.*,){2}.*, *[0+]{,2}91" file
1,721
Posted By ctsgnb
Why not using awk ? $ cat tst2 Date, time,...
Why not using awk ?

$ cat tst2
Date, time, , number 1, number 2, counter...
20130618,912154, ,009912345678,911111111111,10000, , ,abc
20130618,912154, ,009912345678,921111111111,10000, , ,abc...
1,721
Posted By rbatte1
You could try with the expression similar to...
You could try with the expression similar to this:-grep "^[0-9]*,[0-9]*, ,009[19] inputfile
I think that this translates as:-
^ - from start of line
[0-9] - the digits
* - repeated as many...
9,736
Posted By Subbeh
awk -F, -v c=001 'substr($5,0,3)==c' file ...
awk -F, -v c=001 'substr($5,0,3)==c' file

This will print the line if the first three numbers of the 5th field are 001.
3,568
Posted By Jotne
Why not use awk??? awk is a good tool for this...
Why not use awk???
awk is a good tool for this job. Here is another version.
echo a,b,c,d,e,f,g,h,i | awk 'NR>5 && $1~/f/ {print "yes"}' RS=,
yes
This prints yes if an f is found after 5th ,
3,568
Posted By Subbeh
Not sure if this is the best way to do it, but it...
Not sure if this is the best way to do it, but it works:
egrep '.*?,.*?,.*?,.*?,.*?,.*f' file

Edit: This is a better way to approach it:
grep '^\([^,]*,\)\{5\}\(.*f\)' file
3,568
Posted By Subbeh
This will print the line if the letter "f" is in...
This will print the line if the letter "f" is in field 6 or more:
echo a,b,c,d,e,f,g,h,i | awk -F, '{ p=0; for (i=6; i<=NF; i++) { if ($i ~ /f/) p=1 } } p'
3,027
Posted By Yoda
ts=$1 awk -F, -v T="$ts" 'NR > 1 && T >= $1...
ts=$1

awk -F, -v T="$ts" 'NR > 1 && T >= $1 && T <= $2' abc.csv
1,100
Posted By Don Cragun
This should come close, but the 1st line in the...
This should come close, but the 1st line in the 2nd file will be split into fields using the wrong value for FS (since field splitting will be done before FS is reset). Assuming that there could be...
93,881
Posted By cs03dmj
ssh -q -o "BatchMode=yes" user@host "echo 2>&1"...
ssh -q -o "BatchMode=yes" user@host "echo 2>&1" && echo "OK" || echo "NOK"

...will solve your problem, by running quietly and in batch mode (no user present to enter a password). See man...
8,329
Posted By rajamadhavan
How is your SSH authenticating now ? Password or...
How is your SSH authenticating now ? Password or keys ?

If your ssh is configured for password authentication only, I dont think you have to regenerate any keys. Just login with the new password.
7,358
Posted By Corona688
If file transfer had a "go faster" button...
If file transfer had a "go faster" button everyone would be pushing it already...

The return code of sftp arrives in $? like any other command. But this won't tell you which file messed up. I'm...
1,374
Posted By balajesuri
In field 2, match 6 if it is at the beginning...
In field 2, match 6 if it is at the beginning (^'$x') or if it is in the middle (,'$x',) or if it is in the end ('$x'$), and print corresponding $1.

Note: Here, $x is interpreted by shell and the...
1,374
Posted By balajesuri
root# x=6; awk '$2 ~ /^'$x',|,'$x',|,'$x'$/...
root# x=6; awk '$2 ~ /^'$x',|,'$x',|,'$x'$/ {print $1}' file
Showing results 1 to 25 of 29

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