How to use printf to output a shell variable path?
So I created two shell variables: COLUMN1_HEADING, COLUMN2_HEADING.
They have values:
How would I use printf to get it to print an output like this:
Thanks!
Last edited by Scrutinizer; 09-30-2016 at 06:50 PM..
Reason: code tags
Hi greet_sed,
That is close, but there is an extra %s in your printf format string. Since there is only one operand to be formatted, only one %s is needed:
produces the same results you showed us above.
Alternatively, you could also try the following (note the difference between using single quotes to avoid parameter expansions instead of escaping the dollar sign inside double quotes in the format operand):
which also produces the same output.
These 3 Users Gave Thanks to Don Cragun For This Post:
I suppose it depends on what steezuschrist96 actually wanted. Perhaps the output was to include tabs rather than the literal \t characters to line up the output.
To do that, would it be be more of a:-
Output is:-
The columns don't line up because the literal $COLUMN1_HEADING is so long.
Convert to this to line it up:-
... giving you:-
I hope that this help, but apologies if I've got the wrong end of the stick.
I've created a test script, which is located in $HOME/bin. The script runs as expected with no issues. However, upon echo'ing the $path variable the location of my script is not located in any of the directories listed in $path. So my question is, how does shell know where the script is located... (2 Replies)
I am looking to parse a text file output and set variables based on what is cropped from the parsing.
Below is my script I am looking to add this feature too.
All it does is scan a certain area of users directories for anyone using up more than X amount of disk space. It then writes to the... (4 Replies)
If I enter (simplified):
find . -printf "%p\n"
then all files in the output are prepended by a "." like
./local/share/test23.log
How can achieve that
a.) the leading "./" is omitted
and/or
b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
I am using C Shell MKS Toolkit and I ran into a huge problem when setting up some environment variables.:confused:
The csh script that I have as my login script runs fine but very very slow.
When I add a directory to my PATH it seems to slow down shell startup and even slow down the commands. ... (0 Replies)
Hi ,
I wonder if in java I can pipe the below output of the printf into a variable:
System.out.printf(" This is a test %s\n", myVariable);
I want to keep the output of the printf command to create my history array.
Thanks. (2 Replies)
Hi,
I am new to shell scripting.I tried adding an entry to the path variable like below
export PATH=$PATH:/opt/xxx/bin
But am getting an error invalid identifier /opt/xxx/bin
Can someone tell me the error above and correct me .
Thanks and Regards,
Padmini (2 Replies)
Hi!
1. I have a parameter file containing path to log files. For this example both paths are the same, one is stated directly and the second using env variables.
/oracle/admin/orcl/bdump/:atlas:trc:N
${ORACLE_BASE}/admin/${ORACLE_SID}/bdump/:${ORACLE_SID}:trc:N
2. I try to parse the path... (1 Reply)
I set my path environment variable in c shell, using the
syntax below
setenv PATH "${PATH}:/usr/local:/usr/local/bin"
and placed this in $HOME/.login
$HOME/.cshrc
and /etc/.login
/etc/.cshrc
but when I issued echo $PATH or set command
the output does not reflect changes made to... (5 Replies)