The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
2answers
117 views

printf output running over into next line

I have created Bash SS in vi. My output is running over into the line below it. I am new to UNIX so I'm trying to learn. My output is displayed using printf. printf "%-15s %15s %15s %2d\n %2s " ...
4
votes
1answer
54 views

One liner for padding columns (similar to printf) of output from the previous pipe command?

I'd normally use printf to pad each cell with enough whitespace to maintain header position over its respective column. I'm wondering now, whether there's a way to do this on one line. I'm currently ...
3
votes
0answers
111 views

How to create a bash command which creates output that exactly mimics a source text file that can be pasted into bash shell where histexpand is on?

The goal is to create a bash one line command that can be copied and pasted - for instance published on a web forum - and then patches files. See it as a way to distribute a patch file by copy and ...
3
votes
2answers
379 views

Why does Bash history not record this command?

The command printf "#!/bin/bash\n" > t generates an error(bash: !/bin/bash\n": event not found), but hitting the up key does not recall the command so that I can modify it. Why is that? (What I ...
1
vote
1answer
73 views

How to compute a thumbnail filename from the shell?

I started noticing some time ago in Xfce4 that when I sent some file to the Trash, tumbler (the Xfce4 thumbnailer) would cause very high I/O load for quite some time. Upon investigating the issue, I ...
1
vote
3answers
73 views

How to print to the left and right of already printed output

I have a command say printf "%5s1" and its output is: 1 How can I print digit 2 to left and digit 3 to right of already printed 1. So, the output looks like below: 213 So, there is one ...
2
votes
2answers
263 views

Overwriting line in unix shell after printing

How can I modify a line after printing it in unix shell.We can delete the line and write again by using \r as shown below,but how can I overwrite on existing line and not delete it completely and get ...
3
votes
4answers
528 views

Pad a number with a zero

I'm trying to pad zero to a number a=010 printf "%04d" $a 0008 I need the "output" as "0010" it's converting the value..can any one help on this ?? and even tried with typeset a=010 typeset -RZ2 ...
1
vote
1answer
616 views

i/o format with printf in bash-shell

I am trying to output the results of my shell script using printf. To keep the results aligned in column, I am using tab as: printf "%s\t %s\t %s\t %s\t %s\t %s\t %s\n" $i $est $var_m $jk $mst $var_M ...
2
votes
2answers
239 views

Where can I find some good documentation for bash printf?

man printf, info printf and printf --help are all pretty useless to me; I want an explanation of the FORMAT options. For example, I could use: printf '%s\n' foo bar and get output: foo bar From ...
3
votes
1answer
116 views

Setting the column position in printf

How to fix the positions of output string in shell using printf? For example ,if I want to print text TEXT-A at position starting from third position from left and one more text TEXT-B at eleventh ...
3
votes
1answer
88 views

Print arguments to printf in no particular order

How can I refer back to arguments to coreutil's printf in no particular order? This is what I want to avoid: $ printf '%s %s %s %s %s %s %s' a c a c b c a a c a c b c a This is what I would like ...
104
votes
5answers
32k views

Why is printf better than echo?

I have heard that printf is better than echo and I can recall only one instance from my experience where I had to use printf because echo didn't work for feeding some text into some program on RHEL ...
2
votes
1answer
401 views

bash script , echo output in box

I have created this Function , which generate below output on terminal , but this function seems complex, So I posted here for any improvement or for same alternate solution. #!/bin/bash function ...
1
vote
1answer
185 views

Why does printf ignore the IFS when printing out the result of my script?

This is a follow up to a question posted on SO. I've written a script called except which should print all filenames / directories except the ones given like so. $ ls a b c d $ rm $(except b d) $ ls ...
0
votes
1answer
228 views

Pretty print in VIM?

I have few lines that each of them are colon separated values, abc:def:3 Now I could do the reformat with printf plus IFS variable, while read line; do IFS=":" printf "%-20s %-16s %5d\n" ...
2
votes
3answers
2k views

print output to 3 separate columns

MYPATH=/var/www/html/error_logs/ TOTALFILE=$(ls $MYPATH* | wc -l) FILETIME=$(stat --format=%y $MYPATH* | head -5 | cut -d'.' -f1) FILE=$(ls -1tcr $MYPATH* | head -5 | rev | cut -d/ -f1 | rev) ...
0
votes
1answer
643 views

Where to find printf formatting reference?

Where is the offline reference of the format specifiers (e.g., %i, %s) which are supported by the Bash/system printf command? I've looked in help printf, man 1 printf and man 3 printf without luck. ...