Search Results

Search: Posts Made By: thibodc
892
Posted By agama
Your first one; the echo is not necessary. Best...
Your first one; the echo is not necessary. Best to quote it though:


awk '$2 ~/^0:/ && match( $6, "^" v ) && $7 ~/^2[48]/ && $8 ~/^00|^0F|^1F/ {print x;print;getline;print}; {x=$0}' v="$name"...
26,830
Posted By pravin27
perl -e 'use POSIX qw(strftime);$now_string =...
perl -e 'use POSIX qw(strftime);$now_string = strftime "%e-%b-%Y", localtime(time-86400); print $now_string,"\n";'
1,832
Posted By Chubler_XL
p stores previous line w cycles thru 0, 4 and 6...
p stores previous line
w cycles thru 0, 4 and 6
getline;print - fetches next line from infile and prints it.
$1" "$2=="B 0:" field 1 is "B" and field 2 is "0:"

print p;print print previous...
1,832
Posted By Chubler_XL
How about this: awk '$1" "$2=="B...
How about this:

awk '$1" "$2=="B 0:"&&$7~"^(10|11)$"&&$8==w {
print p;print; if(w>2) {getline;print};w=w<8?w+2:0; if(w==2)w=4} {p=$0}' infile
1,461
Posted By elixir_sinari
As you already mentioned, you need your logic to...
As you already mentioned, you need your logic to be applied on sets of data. So, first we need to identify a set. As the Date: lines will always be there, the only way (I could think) of identifying...
1,461
Posted By elixir_sinari
In that case, the following should work (not...
In that case, the following should work (not tested fully though):


awk '/^Date:/{times++} /^Date:/ && times==8 {for(i=1;a[i];i++){
split(a[i],f)
if (a[i] ~ /^B 0:/ && f[7]=="10" && f[8]=="00")...
1,645
Posted By agama
Provided that you quote the variables as you use...
Provided that you quote the variables as you use them, as chihung has done, then multi token strings (with spaces) should be fine.
1,645
Posted By chihung
vehicle1=car vehicle2=bicycle nawk -v...
vehicle1=car
vehicle2=bicycle
nawk -v v1="$vehicle1" -v v2="$vehicle2" 'match($0,v1),match($0,v2)' transportation.txt
3,774
Posted By agama
You should have nawk on a Solaris 10 box, so...
You should have nawk on a Solaris 10 box, so either of these should work and avoid any nasty quoting games:



awk 'match( $0, v ),/bicycle/' v="$vehicle" input-file

nawk -v v="$vehicle"...
3,774
Posted By chihung
vechicle="car" awk '/'$vehicle'/,/bicycle/'...
vechicle="car"
awk '/'$vehicle'/,/bicycle/' transportation.txt


Since you are using '/.../' , second way cannot be used.
8,025
Posted By kevintse
awk 'NR>=3 && /red/' infile
awk 'NR>=3 && /red/' infile
2,186
Posted By Chubler_XL
Umm, I have Version M-12/28/93e and I get: ...
Umm, I have Version M-12/28/93e and I get:

$ printf "%T\n" now
ksh93: printf: T: unknown format specifier

So I'm guessing you need a later version for this feature.

Your probably going...
3,484
Posted By chihung
This list provides index to the abbr month name....
This list provides index to the abbr month name. The 4th column returns from the 'localtime' will give the index of the month. Eg. 2 means Mar. List index starts from 0
...
8,010
Posted By pandeesh
yes. If the scp command gets succeed then && part...
yes. If the scp command gets succeed then && part scp done will be written to file else failure will be written to the file.
8,010
Posted By jim mcnamara
scp sourcefile.txt...
scp sourcefile.txt user@targetsystem:/home/test/dir1 && echo "scp done" || echo "fail" > out.txt
2,495
Posted By balajesuri
nawk 'NR==2{sub(/.*/, "newtext", $3)}'1...
nawk 'NR==2{sub(/.*/, "newtext", $3)}'1 inputfile
Showing results 1 to 16 of 16

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