Skip to main content

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++...)

1 vote
2 answers
173 views

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 ...
Marc Le Bihan's user avatar
2 votes
1 answer
206 views

I have the following (excerpt from a) zsh shell script (the FOLDER environment variable is exported earlier in the code): # Create temporary directory export TMPDIR=$(mktemp -d) # Set TIMEFMT to ...
Markus Klyver's user avatar
1 vote
1 answer
99 views

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'...
Keelung's user avatar
  • 167
2 votes
4 answers
1k views

I am trying to better understand printf so I read multiple pages on this command, but I also stumbled upon different behavior of %q directive. Namely, stated on this page: What is the difference ...
Vlastimil Burián's user avatar
0 votes
0 answers
37 views

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"); ...
KeShAw's user avatar
  • 23
2 votes
0 answers
82 views

The command printf "%d, %f, %o, %s, %x, %X\n" 380 380 380 380 380 380 outputs 380, 20689...2384.000000, 574, 380, 17c, 17C where the second output is a very large (with almost thousand ...
KeShAw's user avatar
  • 23
-1 votes
1 answer
165 views

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 ...
Spartacus's user avatar
-1 votes
3 answers
268 views

I already posted add escape character with bash. I need script to this for every line in a file that starts with {@codeBlock so {@codeBlock: TEstBigquerry.buildPicks} should look like \{@codeBlock:\ ...
MikiBelavista's user avatar
0 votes
1 answer
77 views

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 --> ...
user447274's user avatar
-2 votes
2 answers
342 views

With awk '{ printf "%-15s %s\n", $1, $2 }' renamed | sort -V ... I get good output from the file renamed. It looks like: file1 file1.new But I want to have the output changed to ...
user447274's user avatar
0 votes
0 answers
46 views

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 ...
smf's user avatar
  • 1
7 votes
3 answers
485 views

Bash printf floating number formatting (with %f or %g) is suddenly completely wrong, and changing all the time. An example output: $ export LC_ALL=C $ printf '%g\n' 1 1.20739e+3531 $ printf '%g\n' 1 4....
PlasmaBinturong's user avatar
5 votes
1 answer
518 views

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/...
user137369's user avatar
7 votes
1 answer
2k views

Instead of the following printf '%s\t%s\t%s\t%s\n' 'index' 'podcast' 'website' 'YouTube' I want to store the printf output in a Results variable, how can I do this?
Porcupine's user avatar
  • 2,176
1 vote
1 answer
637 views

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 ...
sgmoore's user avatar
  • 135

15 30 50 per page
1
2 3 4 5
20