2

Bash / echo and pattern

 2 years ago
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.
neoserver,ios ssh client

Bash / echo and pattern

advertisements

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

Edit : Current code #!/bin/bash check=0 while [ $check -ne 1 ]; do ping -c 1 192.168.150.1 >> /dev/null if [ $? -eq 0 ];then echo -ne "\nClient is up! We will start the web server" touch /etc/apache2/httpd.conf echo "ServerName 127.0.

Working with bash charts and doing stuff

I am writing a bash script and need help. This is what I tried: With the help of @merlin2011 #!/bin/bash if [ $# -ne 2 ]; then echo "Usage: `basename $0` <absolute-path> <number>" exit 1 fi if [ "$(id -u)" != "0"

Unix bash cut and grep

I have a text file called db.txt. Some sample lines from the file goes as such: Harry Potter and the Sorcerer's Stone:J.K. Rowling:21.95:100:200 Harry Potter and the Chamber of Secrets:J.K. Rowling:21.95:150:300 Lord of the Rings, The Fellowship of t

Bash echo command not using the escaped character

The bash echo command isn't using the escaped characters like "\n" and "\t" echo "This is test string\nAnd this is next line" For the above input it displays This is test string\nAnd this is next line So how do I print on the

Has anyone experimented, take a look at my bash script and advise you to simplify it more easily?

my task is to create a script that displays the frequency of random characters in the file. The output should display frequency of a to z (case insensitive) in percent. I created the script below and I just wonder if there is a way how to make it sim

Bash Echo Escape Sequences

I'm trying to write a bash script in CentOS that tests the various echo escape sequences. However, when I run the program ./test.sh a I keep getting this error message: bad interpretation: no such file or directory Here is the script: #! /bin/bash #

Bash redirection and stdin

I'm hoping this is a quick question for a guru. I have the following command which works great from the command line: src/protected/yiic shell src/index.php <<< createmvp < /dev/tty This command executes the yiic bash script and passes it the

bash echo in another file does not work

I want to append a line to another file from within my bash script: #!/bin/bash echo "xxx" >> ~/.bashrc However I get: bash: xxx: command not found Try it (the echo "xxx" >> part) from the CLI. It is likely caused by an imp

BASH: Suspend and resume a child script

I want to control a child script somehow. I am making a master script which spawns many children scripts and need to RESUME and PAUSE them on demand. Child Do stuff PAUSE Cleanup Parent sleep 10 RESUME child Is this possible? +++++++++++++++++++++++

How to make php echo and die messages work with the jQuery plugin

I've created a contact form and it's set up to send the form contents via a mail.php file. At the moment it brings up a success/error message on a new blank page via echo and die respectively, but I want to have some kind of notification that pops up

Bash array and loop will not work together

I am pretty new in bash script and can't figure out why this piece of code doesn't work (yes I've googled around). Here's my code: if [ $usertype = normal ] then commands[0]="hi" ; descriptions[0]="get greeted" commands[1]="test&q

Difference between BASH Scripting and AWK

What is the difference between BASH Scripting and AWK? When would I use one over the other?Awk is just another tool that you can call easily from a Bash script. You would call awk when you need to filter data and a built-in function to Bash doesn't (

Extract floating numbers from the string using Matcher and Pattern

Suppose String str="123 abc 123.4 256"; Matcher m = Pattern.compile("\\d+").matcher(scan); while (m.find()) { System.out.println(m.group(0)); } By Using this code i am getting output as: 123 123 4 256 But in output i want it as 123 ,12

PHP echo and redirect

<?php $dateiname = 'daten.txt'; $inhalt =$_POST['vorname'].' '.$_POST['nachname']."; ".$_POST['abteilung'].";".$_POST['strecke']."; ".$_POST['groesse'].' ; '.$_POST['tag'].'.'.$_POST['monat'].'.'.$_POST['jahr'].PHP_EOL.&qu

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK