Search Results

Search: Posts Made By: jaduks
5,081
Posted By jaduks
$ awk ' FNR==NR{arr[$1]=$1;next} $1...
$ awk '
FNR==NR{arr[$1]=$1;next}
$1 in arr{print arr[$1],$2}
' list.txt file.txt
nokia1100 123,000
iphone678 123
cherry123 67,456
nokia4200 23,645

And a different solution:
$ while...
1,354
Posted By jaduks
Something like ? $ cities="Madrid Paris...
Something like ?

$ cities="Madrid Paris Londres Lisboa"

$ echo $cities
Madrid Paris Londres Lisboa

$ c=1 ; for city in $cities; do echo "city_$c=$city"; ((c+=1)); done
city_1=Madrid...
1,701
Posted By jaduks
Hi, you can try something like this: ...
Hi,

you can try something like this:


if ps aux | grep '[/]sbin/mydaemon' > /dev/null
then
echo "mydaemon running"
else
echo "Its down"
fi


Meaning of:

> /dev/null 2>&1
...
9,204
Posted By jaduks
$ awk '{print...
$ awk '{print $1,"\t",(($2+$3)/2)-x,"\t",(($2+$3)/2)+x,"\t",$4,"\t",$5}' x=500 file.txt
cX 165112764 165113764 27 96.7
cX 165142764 165143764 14 53.73
cX 1.65325e+08 ...
9,204
Posted By jaduks
Hi, could you please provide few of sample lines...
Hi, could you please provide few of sample lines from your input file.
25,789
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
...
9,204
Posted By jaduks
Use printf: e.g. $ awk -F ":"...
Use printf:

e.g.

$ awk -F ":" '{sum+=$NF} END {print sum}' data.txt
1.27084e+10

$ awk -F ":" '{sum+=$NF} END { printf ("%0.0f\n", sum)} ' data.txt
12708429091

$ awk -F ":" '{sum+=$NF}...
19,814
Posted By jaduks
Something like this ? $ awk...
Something like this ?

$ awk '{count[$1]++}END{for(j in count) print j":"count[j]}' file.txt
2,922
Posted By jaduks
Using awk: $ awk ' { while ($0 ~...
Using awk:

$ awk '
{
while ($0 ~ /\\$/ ) {
getline record;
$0 = $0 record
}
print $0
}
'...
2,277
Posted By jaduks
There are already a lot of related posts in this...
There are already a lot of related posts in this forum. Please search 'print lines between patterns' in the search bar of unix.com.

One related post:...
2,406
Posted By jaduks
I have tried something with python, ghostdog74,...
I have tried something with python, ghostdog74, please suggest.

def u(list):
set = {}
return [set.setdefault(a,a) for a in list if a not in set]

for line in open("input.txt"):
...
9,513
Posted By jaduks
Hi, You have mentioned ...multiple...
Hi,

You have mentioned

...multiple files based on the number in the 6th column (numbers 1, 2, 3...):..


But your expected output looks different.

Do you mean this ?


$ awk...
3,138
Posted By jaduks
You can also check using 'fuser' command (fuser...
You can also check using 'fuser' command (fuser <filename>)
34,976
Posted By jaduks
What option you have tried with 'cut' ?
What option you have tried with 'cut' ?
18,792
Posted By jaduks
With absence of -i support with sed, you would...
With absence of -i support with sed, you would need to try something like this:


for file in $(find . -type f)
do
sed 's/192.168.0.4/192.168.0.10/g' $file > $file.tmp
...
3,201
Posted By jaduks
Your attempt looks correct. What error you are...
Your attempt looks correct. What error you are getting ?
3,257
Posted By jaduks
Using awk: $ awk ' { for(j=0;j<=NF;j++)...
Using awk:


$ awk '
{ for(j=0;j<=NF;j++)
if ( $j == "janedoe" )
print $1,$j,$(j+1)}
' infile
9,405
Posted By jaduks
You can try something like this. In this...
You can try something like this.

In this example, 2nd,3rd,5th fields are unique in each line.


for i in $(seq 10);
do
echo "a,2,c,d,5,6" | awk -v v=$i 'BEGIN {FS=OFS=","}...
7,225
Posted By jaduks
Using bash parameter substitution techniques: ...
Using bash parameter substitution techniques:

1)
________________
${string##substring}
It deletes the "longest" match of $substring from 'front' of $string.
_________________

$...
3,283
Posted By jaduks
Something like this ? $ for line in...
Something like this ?


$ for line in $(cat file1); do sed "s/;$/$line;/g" file2 ; done > file3
10,650
Posted By jaduks
You can use getopts here. e.g. [ $#...
You can use getopts here.

e.g.


[ $# -ne 4 ] && <some usage function> && exit

while getopts e:d: OPTION
do
case $OPTION in
e) somevar=$OPTARG ;;
d) ...
1,909
Posted By jaduks
Something like this ? $ echo...
Something like this ?


$ echo "<Bundle_Name>this_data</Bundle_Name>" | awk -F "[>,<]" '{print $3}'

this_data

** here I am using two FS
1,333
Posted By jaduks
This might help you $ echo "0001804026"...
This might help you


$ echo "0001804026" | awk -F "" '{print NF}'
9,568
Posted By jaduks
There are a lot of similar posts on transpose of...
There are a lot of similar posts on transpose of row to column. Search transpose in the search box above, one similar one here...
3,519
Posted By jaduks
Use find with -type f or d and then use wc ...
Use find with -type f or d and then use wc ...
Showing results 1 to 25 of 183

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