Is there a command for sed and awk that will only sort the line with more characters?
#cat file
123
12345
12
asdgjljhhho
bac
ss
Output:
asdgjljhhho
#cat file2
11.2
12345.00
21.222
12345678.10
Output:
12345678.10
--- Post updated at 12:40 AM ---
Closing this now. I figured it out.
Thanks
Print the longest line in the file?
awk:
awk '{ x=length } x>max { max=x; save=$0 } END { print save }' file
shell built-ins:
max=0; while read line; do x=${#line}; if [ $x -gt $max ]; then max=$x; save=$line; fi; done < file; echo "$save"
sed: would be (too) complicated.
rdrtx1
3
sed -n "/.\\{$(wc -L < file)\\}/{p;q}" file
grep -m 1 ".\\{$(wc -L < file)\\}" file
awk 'length==l {print;exit}' l=$(wc -L < file) file