File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
7
7
warrant a full blog post. These are mostly things I learn by pairing with
8
8
smart people at [ Hashrocket] ( http://hashrocket.com/ ) .
9
9
10
- _ 395 TILs and counting..._
10
+ _ 396 TILs and counting..._
11
11
12
12
---
13
13
@@ -362,6 +362,7 @@ _395 TILs and counting..._
362
362
- [ Last Argument Of The Last Command] ( unix/last-argument-of-the-last-command.md )
363
363
- [ List All Users] ( unix/list-all-users.md )
364
364
- [ Only Show The Matches] ( unix/only-show-the-matches.md )
365
+ - [ Partial String Matching In Bash Scripts] ( unix/partial-string-matching-in-bash-scripts.md )
365
366
- [ Repeat Yourself] ( unix/repeat-yourself.md )
366
367
- [ Saying Yes] ( unix/saying-yes.md )
367
368
- [ Search History] ( unix/search-history.md )
Original file line number Diff line number Diff line change
1
+ # Partial String Matching In Bash Scripts
2
+
3
+ To compare two strings in a bash script, you will have a snippet of code
4
+ similar to the following:
5
+
6
+ ``` bash
7
+ if [[ $( pwd) == " /path/to/current/directory" ]]
8
+ then
9
+ echo " You are in that directory" ;
10
+ fi
11
+ ```
12
+
13
+ You may only want to do a partial string match. For this, you can use the
14
+ ` * ` wildcard symbol.
15
+
16
+ ``` bash
17
+ if [[ $( pwd) == * " directory" * ]]
18
+ then
19
+ echo " You are in that directory" ;
20
+ fi
21
+ ```
22
+
23
+ [ source] ( http://stackoverflow.com/questions/229551/string-contains-in-bash )
You can’t perform that action at this time.
0 commit comments