Search Results

Search: Posts Made By: 1tempus1
1,413
Posted By Chubler_XL
Your first attempt works if "\n" is a literal...
Your first attempt works if "\n" is a literal string within your file:
$ cat test1
one two|\nmore
another line
done|\n
$ awk '{ sub(/\|\\n/, "\\n"); print }' test1
one two\nmore
another line...
12,019
Posted By Scrutinizer
I would take a look at test statements [ .. ] in...
I would take a look at test statements [ .. ] in your shell script. Probably you left out a quote or forgot to put spaces around the [ and ] or around the = .
12,019
Posted By Scrutinizer
You mean like this: awk...
You mean like this:
awk 'length>=L{riadok=(length==L?riadok RS:x) "Output: " q FILENAME ":" FS FNR FS length FS $0 q} length > L{L=length}END{ print riadok}' q="'" "$@"
12,019
Posted By Scrutinizer
You can use FILENAME and FNR for that: awk...
You can use FILENAME and FNR for that:
awk 'length>=L{riadok=(length==L?riadok RS:x) "Output: " FILENAME FS FNR FS length FS $0} length > L{L=length}END{ print riadok}' "$@"
12,019
Posted By Scrutinizer
Of course it didn't read stdin. You did not...
Of course it didn't read stdin. You did not provide anything on stdin. You would need for example a pipe to do that, like I did with the cat example.
And what code did you use? The one in...
12,019
Posted By Scrutinizer
The awk already does all that it chooses the...
The awk already does all that it chooses the longest line(s) from all files. I just used cat as an example to generate input on stdin for the shell script, you can use any process there. Inside the...
12,019
Posted By Scrutinizer
I a, having a hard time trying to figure out what...
I a, having a hard time trying to figure out what you are trying to do. You mention using reading standard input, but I see no read statements. Besides that would not even be possible, at least you...
12,019
Posted By Scrutinizer
Presuming /usr/local/bin/bash2 exists on your...
Presuming /usr/local/bin/bash2 exists on your system, this will not work:
if ["$0" -gt 0]
there should be spaces and quotes have no business in a numerical context
if [ $0 -gt 0 ]
But seeing if...
12,019
Posted By Scrutinizer
Shell version maxlength=0 while IFS= read -r...
Shell version
maxlength=0
while IFS= read -r line
do
if [ ${#line} -eq $maxlength ]; then
p="${p}
${#line} \"$line\""
elif [ ${#line} -gt $maxlength ]; then
p="${#line} \"$line\""...
12,019
Posted By rdcwayx
awk 'NR==FNR{L=(length>L)?length:L;next}...
awk 'NR==FNR{L=(length>L)?length:L;next} length==L' infile infile
12,019
Posted By Scrutinizer
Try this: awk 'length==L{S[++i]=$0} length >...
Try this:
awk 'length==L{S[++i]=$0} length > L{L=length; delete S; S[i=1]=$0}END{ for(j=1;j<=i;j++)print L,"\""S[j]"\"" }' infile



---------- Post updated at 11:29 ---------- Previous update...
Showing results 1 to 11 of 11

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