I want to see the results of multiple Bash commands in one line.

Asked 2 years ago, Updated 2 years ago, 101 views

Thank you for your help.

 uname-n; cat/proc/meminfo | head-1 | awk' {print$2}'

server1
1112233

The result was

This result can be used as a result of the

sever1112233

I would like to ask if there is a good way.

bash awk

2022-09-30 16:44

5 Answers

linux-How to join multiple lines of file names into one with custom delimiter?- Stack Overflow

 (uname-n; cat/proc/meminfo | head-1 | awk' {print$2}') | tr'\n' ' '

So what do you think?


2022-09-30 16:44

It's already been resolved, but it's a different answer.

$echo-n "$(uname-n)"; cat/proc/meminfo|awk'NR==1 {print$2}'

$ set --$(uname-n; cat/proc/meminfo | awk'NR==1 {print$2}'); echo "$1$2"

$ printf "%s%s\n"$(uname-n; cat/proc/meminfo | awk'NR==1 {print$2}')

$ cat/proc/meminfo | awk-vuname="$(uname-n)"'NR==1 {print uname"""$2}'


2022-09-30 16:44

I would do it like this.

 echo$(uname-n; cat/proc/meminfo|head-1|awk'{print$2}')


2022-09-30 16:44

It's a different solution.
Use paste to combine multiple lines (fixed lines) into a single line.

 (uname-n; cat/proc/meminfo | head-1) | paste- -

If you want to summarize n lines, write n - of paste-.


2022-09-30 16:44

Is that so?

$(uname-n; cat/proc/meminfo|head-1|awk'{print$2}')|xargs
c809051830b8152984


2022-09-30 16:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.