Questions tagged [command-substitution]

Questions about shell command substitution (such as $(command) or command), its mechanism, correct syntax etc. Not to be confused with aliasing.

Command substitution is a facility that allows a command to be run and its output to be pasted back on the command line as arguments to another command.

Examples:

vi `fgrep -l malloc *.c`
vi $(fgrep -l malloc *.c)

Read more:

393 questions
20
votes
2 answers

What is command substitution in a shell?

I'm using Ubuntu 16.04 with Bash and I tried to read in Wikipedia, in here and in here, but I failed to understand the meaning of "command substitution" in shell-scripting in general, and in Bash in particular, as in: $(command) or `command` What…
10
votes
1 answer

Compare two data streams without both being stored as files

I have these two files:- [root@localhost base_filters]# cat aix_old joe amadeus image bill juliet charlie romeo ftp [root@localhost base_filters]# cut -d: -f1 passwd2 henry amadeus image bill julie jennifer charlie romeo harry I am trying to find…
Ankit
  • 1,385
2
votes
5 answers

What problem/pattern justifies using command substitution?

I raised a few server environments with Ubuntu and Bash, on "self managed shell" hosting providers like DigitialOcean, on which I ran Drupal/WordPress applications. All that time I didn't have a necessity to use what's called "command substition". I…
2
votes
1 answer

Command substitution

I would like to create a script on SUSE Enterprise Linux, it first asks for a string (representing a date) and then search for all files in a certain directory which contains the string in its filename. If there is an empty input, todays date should…
1
vote
2 answers

subsitute removing zero numbering

I would like to subsitute in a txt file the followings targets for example "code_000040" by "code_40" and "code_067340" by "code_67340" and so on.., in other words to remove the zeros in the 6 number ids before the real numbering id starts Plaese…
0
votes
3 answers

Is command substitution syntax, $(), considered to be an operator or a command?

I can't find any official documentation that refers to it as one or the other. What, exactly, is the technical distinction between a command and an operator, anyway?
StevieD
  • 915
0
votes
1 answer

How to write a shell script that takes a name of a folder and deletes all subfolders?

I'm stuck with the script which I wrote on Bourne Shell. Script: echo "Who are you?" read Individual echo "Hello,$Individual" echo "Where you want to go?" read Path grep -c "Path" file.txt
0
votes
2 answers

Is a script running inside command substitution?

In a POSIX-compatible shell, is it possible to determine if a script is running inside command substitution? my-outer $(my-inner) $(my-other-inner) For the above example, my-inner and my-other-inner would need to determine if inside command…
dgo.a
  • 779