Search Results

Search: Posts Made By: Storms
5,396
Posted By alister
Unfortunately, it's also incorrect. Take a close...
Unfortunately, it's also incorrect. Take a close at your output. You're clobbering digits with quotes.

Regards,
Alister
12,942
Posted By Scrutinizer
grep works with regular expressions (BRE) by...
grep works with regular expressions (BRE) by default. Did you mean extended regular expressions (ERE) that support alternation (|) and enabling with the "-E" switch?


That will not fly, since...
12,942
Posted By agama
The \b escape pattern doesn't work in my version...
The \b escape pattern doesn't work in my version of awk. I prefer match() to the ~ syntax, but either should work:


awk '
{
if( $0 ~ /[[:space:]](foo|bar|goo)[[:space:]]/ )
...
12,942
Posted By agama
For grep to work with regular expressions you...
For grep to work with regular expressions you need to enable it (preferred) or use egrep:


grep -E "(good|great|excellent)" filename
1,316
Posted By Corona688
The special OFS variable controls what awk's...
The special OFS variable controls what awk's output separator is.
awk -F'|' '{ ... }' OFS='|' filename

You can even use this to transform lines with one separator into a different separator, but...
3,901
Posted By ahmad.diab
another way:- gawk '/^R/&&s{print s ;...
another way:-

gawk '/^R/&&s{print s ; s=""}{s=s$0}END{printf s}' file.txt


o/p
R|This is line 1
R|This is line 2
R|This is line 3
R|This is line 4
R|This is line 5


BR
;););)
3,901
Posted By Franklin52
One way: awk 'NR==1{printf $0;next}/^R/{print...
One way:
awk 'NR==1{printf $0;next}/^R/{print ""}{printf $0}' file
3,901
Posted By ahmad.diab
and to eliminate the space from beginning do the...
and to eliminate the space from beginning do the code:-

gawk '/^R/&&s{sub(/^[ ]/,"",s) ; print s ; s=""}{s=s" "$0}END{sub(/^[ ]/,"",s);printf s}' file.txt
Showing results 1 to 8 of 8

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