Questions tagged [printf]
The shell builtin command that formats and prints data. Questions that deal with printf command or broadly using printf syntax by programming language (like awk, PHP, perl, C++...)
294 questions
1 vote
2 answers
143 views
How changing the terminal letters color and its whole background at the same time, using separate RGB or color codes?
It's often that when I am in a subject involving many processes of two or three kinds, I'm noticing that: one terminal I've opened is dedicated for my subject of kind #1, while another is opened to ...
1 vote
1 answer
79 views
What's the difference in manipulating the array between echo and printf in Bash?
I'm surprised by the difference in manipulating the array between echo and printf in Bash: printf cannot handle += operator Both printf and echo cannot get results of += out of while loop So, why? I'...
0 votes
0 answers
35 views
How does printf() actually work? [duplicate]
When I execute the c file #include <stdio.h> #include <stdlib.h> int main(){ printf("before the system call. I am too excited!\n"); system("ps"); ...
-1 votes
1 answer
137 views
Why is the printf Output Order Not Respected in a Concurrent Scenario with Piped or Redirected stdout?
We are in a concurrent scenario where we have n concurrent processes. By using a synchronization policy (e.g., using pipes or signals), each process can print using printf("string\n") only ...
0 votes
1 answer
68 views
Format output and columms
In Linux in Bash in a for loop i do: ... ; do echo "$i --> $i-new" ; ... The output is than something like this: file1 --> file1-new file2 --> file2-new ... file9 --> ...
0 votes
0 answers
44 views
printf seems to fail in bash [duplicate]
With version GNU bash, version 5.2.32(1)-release (x86_64-pc-linux-gnu) in present Debian testing this command: $ printf '%010f\n' '1234' 000.000000 Doesn't use the number given and changes on every ...
5 votes
1 answer
492 views
printf in Zsh does not shell escape exclamation mark
In Zsh 5.9, we can use printf to shell escape a string: $ printf '%q' 'One! Two' One\!\ Two This produces the correct output of escaping the ! and the space. Now let’s make it as a script: #!/bin/...
1 vote
1 answer
594 views
How do I pass hex characters to printf in a script command? [duplicate]
How do I get printf to output hex characters when run from a script? Suppose I am at the prompt and type printf "\x41\x42" the output I get AB% However if I have a script containing that ...