Home > OS >  Rm - rf! (*.txt) terminal is not why an error in the script complains?
Rm - rf! (*.txt) terminal is not why an error in the script complains?

Time:09-27

Performs the rm - rf in terminal! (*.txt), deleted successfully. TXT file, but put it in the script, complains,
LOCATION=/export/home/byang/Test
If [-d $Location]; Then
CD $Location
LD_LIBRARY_PATH=/usr/local/lib
Export LD_LIBRARY_PATH
Ls *.zip & gt; A.a sc
If the test - s a.a sc; Then
The cat a.a sc | while read the line
Do
Echo $line
CD $LOCATION
7 za e $line - y
The done
Fi
CD $LOCATION
The PWD
Sleep 10
Rm - rf! (*.txt)
The rm * Summary. TXT

Fi
Error message is:
$./test. Sh
./test. Sh: line 19: the syntax error near unexpected token `! (* '
./test. Sh: line 19: ` rm - rf! (*.txt) '
Don't understand why would an error? How to change?

CodePudding user response:

Try the first line with #!/bin/bash or #!/bin/sh,

CodePudding user response:

The first line is a #!/bin/bash, I just didn't write here,

CodePudding user response:

Rm - rf! (*.txt) in parentheses is a special symbol, therefore complains, alternative statement is rm - rf ` find.! -name "*.txt" `. Thanks to the great god,

CodePudding user response:

to log in to a great brother

CodePudding user response:

Rm - rf! (*.txt) under the interactive shell! Extensions said historical records, there is nothing wrong with the grammar, closed in the default script history extensions, so grammatical error,
If you doubt me! The function, man bash, please have a look at to know,

CodePudding user response:

reference 5 floor gaowei190684 reply:
rm - rf! (*.txt) under the interactive shell! Extensions said historical records, there is nothing wrong with the grammar, closed in the default script history extensions, so grammatical error,
If you doubt me! , the function of man bash, please have a look at to know,

https://linux.die.net/man/1/bash
The History Expansion part

The shell supports a history expansion feature that is similar to The history expansion in CSH. This section describes what syntax features are available. This feature is enabled by default for interactive shells, and can be disabled using The option + H to The set builtin command (see shell builtin COMMANDS below). The Non - interactive shells do not perform The history expansion by default.
Content is too much, the end, please check the link
  • Related