Bash / echo and pattern
source link: https://www.codesd.com/item/bash-echo-and-pattern.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Bash / echo and pattern
I have a file which starts with "xx
", I want to find it and do some bash commands on it.
In order to find it, I wrote the next command:
b= 'echo $(ls -r /var/www/xx*)'
But it say that No such file or directory
, while xxbr7.log
is there.
How I can find it?
Because you have a space after the =
so it is interpreting the entire 'echo $(ls -r /var/www/xx*)'
string as a command to execute (with the variable b
set to an empty string in its environment.)
If you're trying to set b
to the string echo /var/www/xxbr7.log
then you want:
b='echo $(ls -r /var/www/xx*)'
with no space after the =
character.
If you're trying to set it to just the string /var/www/xxbr7.log
then you can simplify it:
b=$(ls -r /var/www/xx*)
Or for the special case where there's only one file doing $(ls -r /var/www/xx*)
is unnecessary, you could just say /var/www/xx*
b=/var/www/xx*
Related Articles
Bash script echo and no need to press ENTER
Working with bash charts and doing stuff
Unix bash cut and grep
Bash echo command not using the escaped character
Has anyone experimented, take a look at my bash script and advise you to simplify it more easily?
Bash Echo Escape Sequences
Bash redirection and stdin
bash echo in another file does not work
BASH: Suspend and resume a child script
How to make php echo and die messages work with the jQuery plugin
Bash array and loop will not work together
Difference between BASH Scripting and AWK
Extract floating numbers from the string using Matcher and Pattern
PHP echo and redirect
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK