Printf Inside Printf Linux

[Solved] Printf Inside Printf Linux | Perl - Code Explorer | yomemimo.com
Question : printf linux

Answered by : niransha

#cat file.txt
#1.11135 -66.8286 0.382867 24.6386 0.693014 175.409 0.763907 -97.6113
cat file.txt | awk '{printf "%-5s%-10s%8s%10s\n","A",$1,$2,"-1.0"}' ^%-5start from left, keep 5 digit space to right ^%8 start from right, keep 8 digit space to letf
output : 1 1.11135 -66.8286 -1.0
#123451234567890123456781234567890
%s	a string of characters
%c	character
%d	decimal (integer) number (base 10)
%e	exponential floating-point number
%f	floating-point number
%i	integer (base 10)
%%	print a percent sign
\%	print a percent sign
#advacne version of this, with many new lines,
cat file.txt | awk '{printf "%-5s%-10s%8s%10s\n%-5s%-10s%8s%10s\n","A",$1,$2,"-1.0","B",$3,$4,"-2.0"}' ------------------^repeat
var=0.00
awk '{printf "%4s%7.0f%3s%6s%2s%4.0f%12.3f%8.3f%8.3f%6.2f%7.2f\n", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $var}' < a.pdb >> dest.pdb
sort -nk2 clus_vs_pupulation.dat | tac | head -n 20 | awk -v tot=$total '{s++; printf("%-11s%2.2f%1s\n", $1,($2*100/tot),"%" )}'
more https://alvinalexander.com/programming/printf-format-cheat-sheet/

Source : | Last Update : Thu, 18 Aug 22

Question : printf inside printf linux

Answered by : niransha

printf " $(somecommands_with_prinf) $(somecommands_with_prinf) \n"
eg :
printf "$(cat fol/combine/eps.txt | awk '{printf "%-5s%-10s%8s\n","A",$1,$2}') $variable \n"
add many commands inside $() and .... \n at end
0

Source : | Last Update : Tue, 16 Aug 22

Answers related to printf inside printf linux

Code Explorer Popular Question For Perl