Search Results

Search: Posts Made By: Kibou
1,779
Posted By itkamaraj
$ awk -F\/ '/^title/{print...
$ awk -F\/ '/^title/{print a;print;a="";}/^http/{a=a","$NF}END{print a}' a.txt | sed '1d;s/^,//'
titleA
1234,6789
titleB
5678,1234
titleC
9123,1234,8912
1,779
Posted By RudiC
Try also awk '{printf "%s%s", (NF>1 &&...
Try also
awk '{printf "%s%s", (NF>1 && ONF>1)?",":LF, $NF; LF = RS; ONF = NF} END {printf RS}' FS=/ file
titleA
1234,6789

titleB
5678,1234

titleC
9123,1234,8912It would work also if the...
1,779
Posted By RavinderSingh13
Hello Kibou, Could you please try following....
Hello Kibou,

Could you please try following.

awk '($0 ~ /title/){if(Q){print Q ORS $0;Q=""} else {print};next} {sub(/.*\//,X,$0);Q=Q?Q ($0?OFS $0:RS):$0;} END{print Q}' OFS=, Input_file
...
1,779
Posted By Yoda
awk -F'/' ' !/^http/ && NF { ...
awk -F'/' '
!/^http/ && NF {
T = $0
next
}
/^http/ {
A[T] = ( T in A ? A[T] OFS $NF : $NF )
}
END {
...
1,779
Posted By Scrutinizer
Another approach: awk '{for(i=2; i<=NF; i++)...
Another approach:
awk '{for(i=2; i<=NF; i++) sub(".*/",x,$i); sub(OFS,FS)}1' FS='\n' OFS=, RS= ORS='\n\n' file



--edit--
Yet another option:
awk '{gsub("\n[^\n]*/",","); sub(",","\n")}1' RS=...
2,017
Posted By RudiC
I'm not sure why the sed solution (which, BTW?)...
I'm not sure why the sed solution (which, BTW?) should take significantly longer than the other ones posted. Would you mind to post some comparisons?
2,017
Posted By cjcox
sed solution is fastest, doubt you'll be able to...
sed solution is fastest, doubt you'll be able to beat it by much (virutally immeasurable).

Maybe if we understood what you're wanting to do with the middle data?
2,017
Posted By Scrutinizer
Tested with a 2 GB file (excluding writing to a...
Tested with a 2 GB file (excluding writing to a file which should be similar for all approaches):
$ time sed '1d;$d' greptestin1 > /dev/null

real 0m29.835s
user 0m29.186s
sys 0m0.591s
$ time...
Forum: AIX 01-15-2016
6,791
Posted By agent.kgb
Let's say you have a managed system with two VIOs...
Let's say you have a managed system with two VIOs (vio1 and vio2) and a lot of fully-virtualized LPARs (lpar1, lpar2, ...).

If an LPAR has VSCSI connection, it must be connected to both VIOs.
...
1,372
Posted By RudiC
How about fold -w 80
How about fold -w 80
2,364
Posted By RudiC
You'll see the difference when the maximum number...
You'll see the difference when the maximum number of open files is exceeded.
2,364
Posted By RudiC
If we knew WHAT is "not working as expected"...
If we knew WHAT is "not working as expected" there might be a chance we could help. What's your OS, shell, awk version? What's the result of applying the solutions given to the small sample file you...
2,720
Posted By RudiC
Using terms like "urgent" or "quickly" and/or...
Using terms like "urgent" or "quickly" and/or bumping up posts is not THAT well received in these fora as people are volunteers spending their free time trying to help people solve their problems.
...
2,539
Posted By looney
by awk echo "user lastname" | awk ' { print...
by awk

echo "user lastname" | awk ' { print substr ($1,1,7) substr($2,1,1) } '
2,539
Posted By Aia
Since you did not answer the questions where are...
Since you did not answer the questions where are these names and what do you want to do with the combined names, the following is just an illustration of what it can be done.

#!/bin/bash
...
1,499
Posted By RudiC
awk 'NR==FNR {T[$0]; next} $0 in T' file1 file2 ...
awk 'NR==FNR {T[$0]; next} $0 in T' file1 file2
2967 787
1,499
Posted By RudiC
For that simple scenario, try grep -f file2 file1...
For that simple scenario, try grep -f file2 file1
2967 787
2,356
Posted By Scrutinizer
Actually \+ is a GNU extension. In any sed...
Actually \+ is a GNU extension.

In any sed (including GNU sed) one could use:
sed 's/[^0-9]*\([0-9]\{1,\}\).*/\1/'
or
sed 's/[^0-9]*\([0-9][0-9]*\).*/\1/'

--
In GNU sed one could use the...
362,397
Posted By agama
You are wise to use xargs as it's much more...
You are wise to use xargs as it's much more efficient. The "splat" (*) on your command line is expanding to all files in the directory. What you want is to search in your current directory:


find...
362,397
Posted By hnrz
If the version of find being used supports it, I...
If the version of find being used supports it, I usually use the -delete option as it is usually even faster. Implementations differ but usually the -exec option of find does a fork() and then an...
2,874
Posted By Aia
Actually, they are not alone, it is the...
Actually, they are not alone, it is the concatenation of all of them as in: s=s $1 OFS
OFS stands for Output Field Separator and by default is a single space
2,874
Posted By Scrutinizer
Hi, x is an empty variable, since it was not used...
Hi, x is an empty variable, since it was not used before. In awk it automatically gets the value "" (in string context) when it is created. So it is another way of writing "" (the replacement part of...
2,874
Posted By Aia
x is a variable that never gets a value assigned...
x is a variable that never gets a value assigned to it. sub(".*/",x,$1) in the field $1 substitute the first instance of ".*/" for "".
2,874
Posted By Scrutinizer
Hi Kibou, in addition to what Aia said, the...
Hi Kibou, in addition to what Aia said, the string s is empty when created, and then each time it is appended with the first field ($1) and OFS (by default a space), so the first time, s contains:
4...
3,440
Posted By Don Cragun
This works with the English description of the...
This works with the English description of the desired output, but doesn't preserve the space between strings of digits as shown in the last line of the desired output. To get the desired output,...
Showing results 1 to 25 of 127

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