ln -s $(ls ../*.txt)
When I do the command above it replay with an error message saying : "ln: target '../foo.txt' is not a directory".
foo.txt is the first file that ls command has found in the parent dir.
I am trying to make symbolic links for all the files in the parent directory which ends with ".txt".
Can you please explain why my command did not work ?
You forgot the directory name to put all the links into. If you want them put into the current directory, use
..There's also no need to use
ls, and you'll get the wrong results if any of the filenames contain whitespace or wildcard characters, because those will be processed in the$(...)output. Just use the wildcard directly.