Tag Info

New answers tagged

3

I assume he meant aligned columns, not columnar data in general. That's how I would understand the stringently anyway. For example: Bad: 1 200 3 100 3 400 Good: 1 200 3 100 3 400 In other words, make files that are easy for computers to read, not for humans. Adding spaces to align things makes them pretty and easier for you and me to understand ...


1

I interpret your question that you want to sum up only those numbers in column 3 that are within some numeric range. Try (for sample range [9-12]): awk '$3>=9 && $3<=12 {s+=$3} END {print s+0}' the_file


0

I'm on solaris and needed an answer without sort -s and the accepted answer wasn't working for me. Joeyg on unix.com had the answer: sort-one-column-only cat tmp.txt 1 5 2 3 5 4 1 3 #Sort by 1st column leaving second stable sorted by the 1st. cat -n tmp.txt | sort -k 2,2 | awk '{print $2,$3}' 1 5 1 3 2 3 5 4 #Sort by 2nd column leaving first stable sorted ...


0

Modify your awk script to output tabs and pipe through column -t -s<TAB> ipath=/usr/local/nextone/bin ifile=/root/Nick.csv { date '+%F %T'; "$ipath"/cli iedge list | awk 'BEGIN {OFS="\t"; print "Registration ID", "Ongoing Calls" } /Registration ID/ { id = $3; next } /Ongoing Calls/ { print id, $3 }' | column -t -s$'\t' } ...


1

To get formatted output from awk, use printf: $ "$ipath"/cli iedge list | awk 'BEGIN { print "------------------------------------"; printf "|%-17s|%-16s|\n","Registration ID", "Ongoing Calls"} /Registration ID/ { id = $3; next } /Ongoing Calls/ {print "------------------------------------"; printf "|%-17s|%-16s|\n",id,$3 } END{print ...


0

If you wish to use grep, then you could do something like this: paste <(cat input.txt | grep -oP "Registration ID\s+\K.+") <(cat input.txt | grep -oP "Ongoing Calls\s+\K.+") This is assuming that you saved the output of cli iedge list in some input.txt file.


3

Try this: ipath=/usr/local/nextone/bin ifile=/root/Nick.csv { date '+%F %T'; "$ipath"/cli iedge list | awk -v OFS='\t' \ 'BEGIN { print "Registration ID", "Ongoing Calls"} /Registration ID/ { id = $3; next } /Ongoing Calls/ { print id, $3 }' } >> "$ifile"


0

Assuming that fruit names contain only _ and alphabetic characters. c='(\e|\\033)\[[0-9;]+m' sed -r "s/^($c)?([a-zA-Z_]+)($c)?/& \3/" file | column -t | sed -r "s/^($c[a-zA-Z_]+$c)( +)([a-zA-Z_]+)/\5\4\1/" | sed -r "s/^[^ ]+ +//" Output: \033[0;32;1mgreen_apple\033[0m 1 100 orange 20 19 pineapple 1000 87 avocado 4 30 ...



Top 50 recent answers are included