Linked Questions

56 votes
8 answers
232k views

I'm using BASH, and I don't know how to find a substring. It keeps failing, I've got a string (should this be an array?) Below, LIST is a string list of database names, SOURCE is the reply, one of ...
edumike's user avatar
  • 3,349
14 votes
2 answers
36k views

Output is same, and it always echos need to pull. If I remove the quotes around $text in if condition it throws the too many arguments error. var="$(git status -uno)" && text="On branch ...
11 votes
8 answers
12k views

I want to check if my string contains one or more asterisks. I have tried this: if [[ $date_alarm =~ .*\*.* ]] then ... fi It worked when I launch the script directly, but not if this script is ...
voidAndAny's user avatar
4 votes
2 answers
6k views

In a bash shell, I want to take the take a given string that matches a regex, and then take the part of the string. For example, given https://github.com/PatrickConway/repo-name.git, I want to ...
12 votes
3 answers
374 views

I am currently trying to find a string within a variable that outputs something like this: one,two,three My code: echo "please enter one,two or three) read var var1=one,two,threee if [[ "$var" == ...
hhh0505's user avatar
  • 357
0 votes
3 answers
2k views

if[ xxx ] how to expresss the string or file include '.' I am new to study shell,thanks for any help
0 votes
2 answers
1k views

This question does not answer my question. I have a script that checks the existence of specific environment variables and prints them with their values. Now I want to mask the values of password ...
Joe's user avatar
  • 353
-2 votes
2 answers
489 views

I am wanting to use a switch/ case statement in bash to check if a file name which is a string contains something but also does not. Here is my case: case "$fileName" in *Failed|!cp*) ...
1 vote
1 answer
399 views

I have the following piece of code where I am trying to match the word "test" in the given string: str="some test string" if [ $str == *"test"* ]; then # [: too many ...
meJustAndrew's user avatar
  • 6,769
0 votes
3 answers
468 views

I'm trying to write a small backupscript which should get executed every hour via cronjob. While the script does monthly/weekly/daily backups and these work, i also would like to perform hourly ...
quarkz's user avatar
  • 3
1 vote
1 answer
421 views

I am trying to understand a piece of code here and as I am not an expert on bash, I am struggling to find out what the below if does: if [[ "4ドル" == *"-a "* ]]; then I understand ...
1 vote
3 answers
131 views

So this is admittedly for university, but I can't find the answer anywhere, nor online, nor in the lecture notes. I basically take a parameter, and have to search, if that is part of a longer string ...
Bozont's user avatar
  • 25
3 votes
0 answers
226 views

Am having difficulty checking if the contents of a variable contains a certain value or not e.g "Device_info" The main code if [ "${NUMBERRESULTS}" -eq 10 ] then echo "Success" else echo "...
Steady_Eddy's user avatar
1 vote
2 answers
82 views

I have a string given below: string1 = "Hello there, my name is Jack. Hello there, my name is Jack. Hello there, my name is Jack." I'm taking the following input from the string: read ...
1 vote
0 answers
73 views

Similar to how in python you can do 'if letter in string:', I'm trying to imitate this in bash. The code is below: SYMBOLS="ABC" msg="alskdfjAasdksdfh!?asdflkjhghrg" # Loops through each letter in ...
bmcisme's user avatar
  • 57

15 30 50 per page
1
2 3 4 5 6