All Questions
10 questions
0
votes
1
answer
345
views
Bash - setting a string variable and printf
I am setting a variable as follows and when I print it out I get something unexpected.
sql="values ('$yy-$mm-$dd $time','$tz', $load)"
printf "%s\n" "$sql"
)alues ('2011-...
1
vote
1
answer
1k
views
Bash: Reuse printf variables in output
Is it possible to use the variables passed to printf more than once in the formatting?
For example, with this line:
printf 'Hi %s, welcome to %s. %s is a great place to work. Thanks %s.' "John&...
-1
votes
3
answers
114
views
How do I output all BASH results of find to a single variable? More details in post
LATEST UPDATE:
I nearly have it figured out with some help from Richard Jessop and his comment. This is the output I currently have:
(\
"DSC009.jpg"\
"wallpaper.png"\
"image732.bmp"\
"animated.gif"\
...
1
vote
1
answer
442
views
How to use a bash variable to hold the format of find's printf statement [duplicate]
How can bash use a variable for the format of find's -printf statement? I am trying to convert the following:
find ./ -type f -printf "File: %p has modification time [%TY-%Tm-%Td %TH:%TM:%TS %TZ]\n"
...
0
votes
0
answers
41
views
Bash: on the escapping of the variables within printf [duplicate]
I have a script in bash which print some file with another script which do again the same job (the first script print another executable script which again produce the third one):
#!/bin/bash
# it is ...
0
votes
3
answers
1k
views
An escaping of the variable within bash script
My bash script writes an another bash script using printf.
printf "#!/bin/bash
HOME=${server}
file=gromacs*
file_name=\$(basename "\${file}")
date=\$(date +"\%m_\%d_\%Y")
for sim in \${HOME}/* ; do
...
0
votes
3
answers
147
views
Variables within the printf
Using bash I need to print some txt file which actually is another python script consisted of some tittles moved into the variable (t) within the main script
t="test"
printf "import pymol
cmd.load("$...
1
vote
2
answers
1k
views
Expand a variable with spaces for printf
My script constructs variables into a given order depending on a table to be printed. But if there are any spaces in the end string, printf treats it as a separate column. Imagine the following:
...
0
votes
2
answers
657
views
Bash: Variable substitution in quoted string looks like something from the Twilight Zone
I've got a bash script that's reading essentially the output of telnet (actually socat to a unix domain socket).
while read -r LINE; do
if [ "$USER_DATA_FLAG" == "true" ]; then #Evaluates to ...
69
votes
6
answers
76k
views
How do I print some text in bash and pad it with spaces to a certain width?
I'm echoing some text in a bash script with a variable in it, and want to pad that variable so it will always have the appropriate ammount of spaces to the right to keep the rest of the text aligned.
...