Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine two shell commands into one output in shell

Tags:

bash

shell

I am trying to combine multiple commands into a single output.

#!/bin/bash

x=$(date +%Y)
x=$($x date +m%)

echo "$x"

This returns

./test.sh: line 4: 2011: command not found

like image 987
Jon Avatar asked Dec 17 '22 17:12

Jon


1 Answers

x=$(echo $(date +%Y) $(date +%m))

(Note that you've transposed the characters % and m in the month format.)

like image 151
rlibby Avatar answered Jan 04 '23 23:01

rlibby