Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

printf @ bash

printf "My brother %s is %d years old.
" Prakash 21
Comment

printf linux

#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
","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
%-5s%-10s%8s%10s
","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
", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $var}' < a.pdb >> dest.pdb

more https://alvinalexander.com/programming/printf-format-cheat-sheet/
Comment

printf inside printf linux

printf " $(somecommands_with_prinf) $(somecommands_with_prinf) 
" 

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

PREVIOUS NEXT
Code Example
Shell :: do command in a command linux 
Shell :: react native youtube install 
Shell :: bash if else if 
Shell :: git rebase i 
Shell :: with which command make file and directory in linux 
Shell :: curl command parameters 
Shell :: installing nginx on docker container 
Shell :: ubuntu adding a monitor 
Shell :: packet tracer 2.7.1 Full Config P2P-3 Router 
Shell :: ssh set owner 
Shell :: O arquivo C:UsersjukinAppDataRoaming pmyarn.ps1 
Shell :: install gcmcore debian 10 
Shell :: how to use valet to share localhost url to outside 
Shell :: dd command to add image to usb 
Shell :: npm -g mac privileges 
Shell :: run specific logrotate 
Shell :: touch file bash insert text 
Shell :: ffmpeg scale but keep aspect ratio 
Shell :: scan for unused ports linux 
Shell :: consolidated version yarn.lock 
Shell :: Error when install irazasyed/telegram-bot-sdk in laravel 8 
Shell :: linux bitcoin app 
Shell :: install ntopng on ubuntu 20.04 
Shell :: permission denied while doing set-executionpolicy 
Shell :: close adb shell 
Shell :: docker toolbox windows clean 
Shell :: disable huge pages on Linux xmrig 
Shell :: linux audacity installieren 
Shell :: open command in debian 
Shell :: bash merge directories 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =