Linked Questions

2 votes
3 answers
20k views

What does $( ... ) mean in the shell? [duplicate]

I don't understand what does the dollar sign do. Especially in this context: for url in $(cat example.txt); do host $url;
user avatar
  • 41
4 votes
2 answers
506 views

Command substitution declaration syntax in bash - which of these two is better practice? [duplicate]

This is part of a bash find loop, and I wondered which is more correct syntax and why? filename="$(echo "$i" | cut -c5-)"; filename=`echo "$i" | cut -c5-`; Both function for the purpose of getting ...
user avatar
  • 493
4 votes
1 answer
257 views

Different behavior of $() and `` [duplicate]

% PATH="MYPATH" % VAR="PATH" % echo $(eval echo \$$VAR) MYPATH % echo `eval echo \$$VAR` 5707VAR ^^ This is the process number. I thought those two were exactly the same, but obviously there are ...
user avatar
  • 1,559
2 votes
1 answer
380 views

What's the practical difference between `command` and $(command)? [duplicate]

Both give the output of the command, so what is the semantic difference between the two? Some reading led me to suspect is that $(command) is Bash syntax, and the back quotes are integrated into Unix ...
user avatar
  • 123
0 votes
2 answers
314 views

What's the difference of get command output using`command`and $(command) in Shell? [duplicate]

What is the difference in collect a command output in Shell script using `command` and $(command)? For example: # IP1=$(ifconfig eth0 | grep -e "inet " | cut -d: -f2 | awk '{print $1}') # IP2=`...
user avatar
1 vote
0 answers
74 views

What's the difference between `` and $()? [duplicate]

When you want to return a command line output, you may consider using two methods: `cat file` or $(cat file). As far as I know, they are equivalent before my eyes. Is there a difference between both? ...
user avatar
0 votes
0 answers
49 views

What is difference between `` and $() for command-substitution in bash scripting? [duplicate]

I'm new to Linux and StackExchange. My English is pretty bad, and I'm sorry for mistakes. What is the differences between `` and $()? Does it matter what to use and when? I'll be grateful for ...
user avatar
443 votes
17 answers
221k views

Get exit status of process that's piped to another

I have two processes foo and bar, connected with a pipe: $ foo | bar bar always exits 0; I'm interested in the exit code of foo. Is there any way to get at it?
user avatar
240 votes
6 answers
438k views

What does ` (backquote/backtick) mean in commands?

I came across the following command: sudo chown `id -u` /somedir and I wonder: what is the meaning of the ` symbol. I noticed for instance that while the command above works well, the one below does ...
user avatar
  • 2,511
31 votes
4 answers
100k views

How to use "cat" command on "find" command's output?

I want to redirect the output of the find command to cat command so I can print the data of the given file. So for example if the output of find is /aFile/readme then the cat should be interpreted ...
user avatar
  • 421
24 votes
2 answers
2k views

The old ticks vs parentheses issue: confused

Since being corrected many years ago, I switched from backticks to $() for command expansion. But I still prefer the backticks. It is fewer keystrokes and does not involve the Shift key. I understand ...
user avatar
21 votes
4 answers
14k views

bulk rename (or correctly display) files with special characters

I have a bunch of directories and subdirectories that contain files with special characters, like this file: robbie@phil:~$ ls test�sktest.txt test?sktest.txt Find reveals an escape sequence: ...
user avatar
  • 313
19 votes
6 answers
3k views

Use system command instead of Bash builtin without specifying the full path

I use Bash as my interactive shell and I was wondering if there was an easy way to get Bash to run a system command instead of a shell builtin command in the case where they both share the same name. ...
user avatar
10 votes
3 answers
4k views

How to check if stdin is /dev/null from the shell?

On Linux, is there a way for a shell script to check if its standard input is redirected from the null device (1, 3) *, ideally without reading anything? The expected behavior would be: ./...
user avatar
15 votes
2 answers
4k views

Difference of using () and $() to execute a series of commands

I am currently trying to make a script that creates bytes that will be piped as input to netcat. Here is the idea of the script: (perl -e "print \"$BYTES\x00\"; cat file; perl -e "print \"More ...
user avatar
  • 389

15 30 50 per page