Search Results

Search: Posts Made By: sathyaonnuix
16,637
Posted By Corona688
The only dependable things cron gives you are the...
The only dependable things cron gives you are the SHELL, LOGNAME, and HOME environment variables as determined from that user's /etc/passwd entry. The rest just gets inherited from what cron had,...
1,113
Posted By vidyadhar85
This is called Shell's parameter expansion.....
This is called Shell's parameter expansion.. refer shell man page for more information or below link

Shell Command Language...
3,240
Posted By Franklin52
Try: awk -F,...
Try:
awk -F, 'NR==FNR{if($3>m){m=$3}next}$3==m{s=s?s FS $1:$1}END{print s}' file file
2,425
Posted By Jotne
netstat -a | grep -w 9071 |grep ESTABLISHED | awk...
netstat -a | grep -w 9071 |grep ESTABLISHED | awk '{print $5}' | cut -d'.' -f1
This can be reduced from 5 commands to 2
netstat -a | awk '/ESTABLISHED/ && /9071/ {split($5,a,"."); print a[1]}'
12,116
Posted By radoulov
awk 'NR == FNR { # while reading the fist...
awk 'NR == FNR {
# while reading the fist input file
# store the names in an array
# keyed by the IPs
iton[$1] = $2
next
}
# if the IP has an associated name
# assign its value to...
12,116
Posted By Scott
Only if the closing EOF is indented with a TAB...
Only if the closing EOF is indented with a TAB (or nothing at all - it won't work if those are spaces before it).

A note to radoulov's solution (which is nice :)). Moving a temporary file over an...
12,116
Posted By Scott
Doubtless you can simplify the code further, i.e....
Doubtless you can simplify the code further, i.e. by using awk to read both files and substitute the correct values. You would then write this to a temporary file and copy that over the original.
...
12,116
Posted By radoulov
You could use use awk: awk 'NR == FNR { ...
You could use use awk:

awk 'NR == FNR {
iton[$1] = $2
next
}
($1 in iton && $1 = iton[$1]) || 1
' file2 file1 > _tmp_file_ &&
mv -- _tmp_file_ file1

If the original order is...
5,862
Posted By rangarasan
Please check the output of my command and not the...
Please check the output of my command and not the input file.


# awk -v l="15" '{s="%-"l"s\n";printf(s,$0);}' file|awk '{print length($0);}'
15
15
15


Cheers,
Ranga:)

---------- Post...
5,862
Posted By rangarasan
Hey, Welcome to The UNIX and Linux Forums, ...
Hey,

Welcome to The UNIX and Linux Forums,

Please use code tags for data samples and codes. code tag button look like https://www.unix.com/images/editor/code.png

You should use printf to...
12,224
Posted By rdrtx1
try (modification on Corona688's solution): awk...
try (modification on Corona688's solution):
awk -F"," -v OFS="," 'NR>1{ $2+=int((NR-2)/5000) } 1' infile > outfile
12,224
Posted By Corona688
awk -F"," -v OFS="," 'NR>1{ $2+=int((NR-1)/5000)...
awk -F"," -v OFS="," 'NR>1{ $2+=int((NR-1)/5000) }' infile > outfile
2,564
Posted By Scrutinizer
Hi sathyaonnuix, A[NR%y] has the function of a...
Hi sathyaonnuix, A[NR%y] has the function of a rolling buffer, it contains a number of lines that is equal to y, which is the number of lines that should not be printed at the end of the input file.....
2,135
Posted By pamu
$ awk -F "|" 'f==1{A[$1,$2]++;B[$1,$2]=$1 FS $2...
$ awk -F "|" 'f==1{A[$1,$2]++;B[$1,$2]=$1 FS $2 FS FILENAME}
f==2{A[$1,$2]++;B[$1,$2]=B[$1,$2]?B[$1,$2]","FILENAME:$1 FS $2 FS FILENAME}
f==3{A[$1,$2]++;B[$1,$2]=B[$1,$2]?B[$1,$2]","FILENAME:$1 FS...
2,559
Posted By pamu
Try sth like this... value=1 cal 10...
Try sth like this...

value=1

cal 10 1987 | awk -v var="$value" 'NR==2{n=split($0,P)}
NR>2{for(i=1;i<=7;i++){if(var == $i){print P[7-NF+i]}}}'
2,578
Posted By MadeInGermany
I am not sure if this is correct: sed -n...
I am not sure if this is correct:
sed -n '/^\.\.\.\./!H; /^\.\.\.\./{x; /stopped/d; /date.*13\/12\/2012/d; p;}' example
5,709
Posted By mjf
Something like this? awk '{ sum+=$9}...
Something like this?


awk '{ sum+=$9} {print} END {printf "%60s\n", "Total SGD " sum}' file



Dec 24 11:31:10 0000008b 9911662486 Answered Price SGD 0.003 PERIOD: 0 m 6 s
Dec 24 11:21:42...
29,721
Posted By Scott
You can just sum it up as you go through each...
You can just sum it up as you go through each line:

$ cat myScript
awk '{
TR=0
for( I = 1; I <= NF; I++ ) {
TR += $I
TC[I] += $I
printf( "%6d", $I )
}
print " = " TR...
5,709
Posted By guruprasadpr
Hi awk '{x+=$9;}END{print "Total SGD "...
Hi


awk '{x+=$9;}END{print "Total SGD " x;}1' file

Guru.
149,025
Posted By complex.invoke
Tetris Game -- The Art Of Shell Programming
GitHub - deepgrace/tetris: Tetris implementation in all kinds of Programming Languages (https://github.com/deepgrace/tetris)

Usage: bash Tetris_Game [ <runlevel> [ <previewlevel> [ <speedlevel> [...
3,560
Posted By Corona688
$0 means 'the entire unmodified line', pure and...
$0 means 'the entire unmodified line', pure and simple. You can change what 'line' means to awk, but by default, it uses newlines like everything else.

You can think of it as a hash table if you...
1,491
Posted By binlib
The offset in TZ for GNU date (or libc?) seemed...
The offset in TZ for GNU date (or libc?) seemed can't be bigger than 24. You need to convert the day part into -d argument as you said. Either override your date command with a function:
function...
10,139
Posted By hergp
Your wget example retrieves a https-URL. You have...
Your wget example retrieves a https-URL. You have set a http-proxy in wgetrc, but not a https-proxy. Add


https_proxy=http://str-www-proxy2:8080
to your wgetrc file and retry.
2,784
Posted By pamu
Append http://en.wikipedia.org and then use wget....
Append http://en.wikipedia.org and then use wget.

like

wget http://en.wikipedia.org/wiki/File:Ward_Cunningham_-_Commons-1.jpg
2,216
Posted By Don Cragun
You're making this much too hard on yourself. ...
You're making this much too hard on yourself. When you set a variable in the shell, parameter expansion occurs in double quoted strings and that is all you need here.
Adding the eval also causes...
Showing results 1 to 25 of 34

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