Bash - command substution not working

For some reason I cannot use command substitution in my bash shell in Fedora.

 
 The following commands give me the following outputs-:
  
 [Sreyan@localhost ~]$ $(( $(w| wc -l) - 2 ))
Command not found. 
 
[Sreyan@localhost ~]$ `ls`
Command not found. 
 
[Sreyan@localhost ~]$ $("date")
Command not found. 
 [Sreyan@localhost ~]$ $(ls)
Command not found. 
 [Sreyan@localhost ~]$ $(( $(date +%s) / 86400 ))
Command not found.
 

What am I doing wrong ? I cannot complete my assignments without command substitution. That's why I am posting here. I am on Fedora 14 32bit.

What is your PATH environmental variable set to?
(hint: echo $PATH )

/usr/lib/qt-3.3/bin:/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/Sreyan/bin

You do not need to put date , ls , or any other COMMAND to put in quotes when executed in a terminal.

Just like this is enough:

date
ls
w

To actualy work with them, it is suggest to echo them when encapsuled in a XY (what is this called again?).
As in:

echo $(( $(w| wc -l) - 2 ))
echo $(( $(date +%s) / 86400 ))

Because if you just call:

$(( $(date +%s) / 86400 ))

It will fail, because its result is not a COMMAND .

Furthermore (but not relevant to the post), F14 is way end of life, 21 is coming out soon.

Hope this helps

2 Likes

Thanks that solved my problem. Don't know what you mean by F14 though.

F14 = Fedora 14
Just saying that version 20 is out: Fedora Project - Get Fedora: Desktops, Other Formats, Spins, Cloud Images, ARM or Secondary Arches.

Cheers

I'd recommend updating tot he latest version. 14 is a very long way behind.