So I am trying to get sessions from tmux ls
, the output is something like this:
mc: 1 windows (created Mon Jun 17 15:53:39 2019) [108x37]
test: 1 windows (created Mon Jun 17 15:53:55 2019) [108x37]
So I pass it to grep in my script but it tries to execute it I guess,
#!/bin/sh
tmux ls | while read x;
do
TEST=$("$x" | grep -P '^.*?:')
echo "$TEST"
done
The output is this:
root@server0:/home/mc# ./test.sh
./test.sh: 5: ./test.sh: mc: 1 windows (created Mon Jun 17 15:53:39 2019) [108x37]: not found
./test.sh: 5: ./test.sh: test: 1 windows (created Mon Jun 17 15:53:55 2019) [108x37]: not found
Can someone tell me the problem? I couldn't find any solution because I don't know what to search for that problem.