How print two command stdout one line

Hi everyone Gurus, I have question I wanna see excute command again

e.g.

$ pwd; hostname

but one line

$ /home/user    myhostname

Hi, try:

{ pwd; hostname; } | paste - -
echo "$(pwd)  $(hostname)"
pwd | tr '\n' '\t' ; hostname
3 Likes

many ways to skin that "cat":

printf "%s %s\n", "$(pwd)" "$(hostname)"
(pwd; hostname) | sed '$!N;s/\n/ /'
2 Likes

Hi
echo $PWD $HOSTNAME
you can just insert two variables where you need
"$PWD $HOSTNAME"

1 Like

And if you are using KSH:
echo $(pwd;hostname)

4 Likes

It works in bash also

1 Like

Note: The approaches with unquoted command and parameter expansions are subject to field splitting by the shell and may not render correct results, for example in the case of paths with spaces in them, with IFS set to its default value.

Note2: The variables PWD and HOSTNAME may not always be available or set reliably.

3 Likes

Thank a lot gurus

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.