Search Results

Search: Posts Made By: zorrox
3,281
Posted By RudiC
Now comes the full beauty of the proposal in...
Now comes the full beauty of the proposal in post#3 into play: if you insert

LINE=${LINE//$'\t\t'/$'\t'x$'\t'}; right after the do, it might fly...
3,281
Posted By Scrutinizer
Yes this is a problem for bash. If you have...
Yes this is a problem for bash. If you have either ksh93 or zsh on your system (if not you can install it) then you can do this:
while IFS=$'\t\t' read -A CU
do
curl -v -b cookie.txt -d...
3,281
Posted By Scrutinizer
In bash, if you read straight into an array you...
In bash, if you read straight into an array you do not need to set and unset IFS globally, so RudiC's suggestion modified, becomes:
while IFS=$'\t' read -a CU
do
curl -v -b cookie.txt -d...
3,281
Posted By RudiC
With bash, this snippet - although being far from...
With bash, this snippet - although being far from complete and error proof - could point you in the right direction:

OLDIFS="$IFS"
IFS=$'\t'
while read LINE
do CUARR=($LINE)
echo...
5,855
Posted By Scrutinizer
Alright, but the input specification keeps...
Alright, but the input specification keeps changing, are you sure this is that last exception?

Try:

awk -F'[.,:] *' ' # Use dot, command and colon as fields separator
/^[A-E]\./ { ...
5,855
Posted By Scrutinizer
The difference is that apart from the capital...
The difference is that apart from the capital letters for QUESTION, there is a space after the colon with zero or more spaces behind it...

So, try:
awk -F'[.,:] *' ' # Use dot, command...
5,855
Posted By Scrutinizer
Try: awk -F'[.,:]' ' # Use dot,...
Try:
awk -F'[.,:]' ' # Use dot, command and colon as fields separator
/^[A-E]\./ { # Store the choices in array A with index the first field (letter A-E)
i=$1
$1=x...
4,730
Posted By Akshay Hegde
awk '/begin/{s=""}{s=s ? s ORS...
awk '/begin/{s=""}{s=s ? s ORS $0:$0}/end/{if(s~/pattern1/)print s RS}'


Glad to know that it worked for you..

So here is details

/begin/{s=""} --> Search keyword begin, if keyword found...
4,730
Posted By anbu23
sed -n "/begin/,/end/{H;/begin/h;};...
sed -n "/begin/,/end/{H;/begin/h;}; /end/{g;/pattern1/p;}" file
4,730
Posted By Akshay Hegde
Try : $ awk '/begin/{s=""}{s=s ? s ORS...
Try :

$ awk '/begin/{s=""}{s=s ? s ORS $0:$0}/end/{if(s~/pattern1/)print s RS}' file
begin
def
ghi
pattern1
end

begin
pattern1
jkl
end
10,300
Posted By RudiC
As Scrutinizer says, there are some caveats. If...
As Scrutinizer says, there are some caveats. If you're sure that we are dealing always with paired lines, and /abc/ is always the first in that pair, you might try a getline after an /abc/ match to...
10,300
Posted By Scrutinizer
I think you would need to adjust your solution so...
I think you would need to adjust your solution so that x gets erased once a match for a different line gets found and then you would also need to test if x contains something before printing both x...
10,300
Posted By RudiC
Actually your first proposal would work once your...
Actually your first proposal would work once your add/replace some curly brackets:awk '/abc/ {if ($1>10) {print}};/xyz/ {if ($2>5) {print}}' file
12 14 3 20 45 abc
33 19 10 21 49 xyz
55 41 13 62...
10,300
Posted By Scrutinizer
That is a little bit more complicated. Try...
That is a little bit more complicated. Try something like:
awk 'NR%2{p=$0; m=$1; next} p~/abc/ && m>10 && /xyz/ && $2>5{print p ORS $0}' file

output:
55 41 13 62 24 abc
12 44 16 54 62 xyz
10,300
Posted By Scrutinizer
Hi, are you looking for something like this? ...
Hi, are you looking for something like this?

awk '(/abc/ && $1>10) || (/xyz/ && $2>5)' file

Output:
12 14 3 20 45 abc
33 19 10 21 49 xyz
55 41 13 62 24 abc
12 44 16 54 62 xyz
9,060
Posted By itkamaraj
bash-3.00$ ./test.ksh 3.33 5.34 4.17056 ...
bash-3.00$ ./test.ksh
3.33
5.34
4.17056
bash-3.00$ cat test.ksh
nawk '{print $7}' test.txt | sort -n | head -1 #min
nawk '{print $7}' test.txt | sort -nr | head -1 #max
nawk...
9,060
Posted By bartus11
awk 'NR==1{min=$7;max=$7;sum+=$7;next}{if...
awk 'NR==1{min=$7;max=$7;sum+=$7;next}{if ($7<min) min=$7;if ($7>max) max=$7;sum+=$7}END{print "min: "min", max: "max", avg: "sum/NR}' file
4,668
Posted By ahamed101
ARGV will have the values *.pdf i.e. a.pdf, b.pdf...
ARGV will have the values *.pdf i.e. a.pdf, b.pdf and c.pdf
so ARGV[1] is a.pdf, ARGV[2] is b.pdf and so on
this is what the code does

1. reads from the file "file1" # while ((getline < file1) >...
4,668
Posted By radoulov
The code below will rename filex-1.pdf to...
The code below will rename filex-1.pdf to filex-1-apple.pdf:


printf '%s\n' *.pdf |
sort -t- -k2n |
awk -F. 'getline f1 < "file1" {
printf "mv -- \"%s\" \"%s-%s\.%s\"\n", \
...
2,121
Posted By ahamed101
Try this... #to delete 1 and 3rd...
Try this...

#to delete 1 and 3rd <tr>...</tr> pairs
awk '/<tr>/ {i=i+1} {if(i==1 || i==3){next} print}' file
if further if you want to delete say only the second pair, tweak the above code as...
1,806
Posted By ctsgnb
$ lastline=$(( $(wc -l <tst)-20 )) $ sed...
$ lastline=$(( $(wc -l <tst)-20 ))
$ sed '1,'$lastline'!d' tst
1
2
3
4
5
6
7
8
9
10
1,806
Posted By mirni
Use double quotes sed "$start,$end d" fileOr,...
Use double quotes
sed "$start,$end d" fileOr, if you have metacharacters in there, use single quotes and turn them on and off to get the $start and $end in:

sed ''$start','$end' d' file


The...
1,739
Posted By rdcwayx
awk '{for (i=1;i<=$2;i++) printf "wget...
awk '{for (i=1;i<=$2;i++) printf "wget http://somewebsite/page=%s&line=%s\n",$1,i}' infile |sh
1,739
Posted By mirni
while read p cnt ; do for i in `seq $cnt` ;...
while read p cnt ; do
for i in `seq $cnt` ; do
echo "wget http://smthn/page=${p}&line=$i"
done
done < input
1,234
Posted By zeroone
here you go.. grep ayat >>>>insert file-name...
here you go..
grep ayat >>>>insert file-name here<<<< | sed 's/^.*), //' | sed 's/,.*$//' | nl

cheers
Showing results 1 to 25 of 27

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