Search Results

Search: Posts Made By: jaduks
82,975
Posted By jaduks
This can be done using associative array in awk. ...
This can be done using associative array in awk.



$ cat nayan.out
saman 1
gihan 2
saman 4
ravi 1
ravi 2

$ awk '{arr[$1]+=$2} END {for (i in arr) {print i,arr[i]}}' nayan.out >...
36,072
Posted By jaduks
A awk one to remove leading 0's $ echo...
A awk one to remove leading 0's

$ echo "0000000231" | awk '{print $1 + 0}'
231
62,572
Posted By jaduks
A handy one :-) $ cat daysdiff.sh ...
A handy one :-)

$ cat daysdiff.sh
D1=`date +%s -d "2007-12-19"`
D2=`date +%s -d "2008-02-09"`
((diff_sec=D2-D1))
echo - | awk -v SECS=$diff_sec '{printf "Number of days :...
24,919
Posted By jaduks
$ cat details.txt 2424|asdsd|121 ...
$ cat details.txt
2424|asdsd|121
1212|adad|9898
12|6767

$ awk 'BEGIN {OFS="|"} {print $0,FILENAME}' details.txt
2424|asdsd|121|details.txt
1212|adad|9898|details.txt
12|6767|details.txt
...
Showing results 1 to 4 of 4

 

Featured Tech Videos

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