This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #Recursively traverse the directories | |
| traverseDirectory(){ | |
| for fileName in `ls $1/` | |
| do | |
| echo "$1/$fileName" | |
| if [ -x $1/$fileName ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abc | |
| oiewjf | |
| cdeoewjfmpew | |
| oiwegm | |
| ab | |
| bc | |
| abc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| pattern="abc" | |
| replacedValue="cde" | |
| sed -i "s/$pattern/$replacedValue/g" sedInput.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #Pass arguments of txt file via command line | |
| while read line | |
| do | |
| echo $line | |
| done < "$1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| while read ip datee timee | |
| do | |
| echo "Details:" | |
| echo $ip | |
| echo $datee | |
| echo $timee | |
| echo "" | |
| done < "$1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| readFile(){ | |
| while read line | |
| do | |
| echo $line | |
| done < "$1" | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #Recursively traverse the directories | |
| traverseDirectory(){ | |
| for fileName in `ls $1/` | |
| do | |
| if [ -d $1/$fileName ]; then | |
| echo "$1/$fileName" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #Recursively traverse the Directories and | |
| #Print the file contents inside those directories. | |
| readFile(){ | |
| while read line | |
| do | |
| echo "$line" | |
| done < "$1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Do not use space before and after equal sign. | |
| a=1 | |
| b=3 | |
| sum=`expr $a + $b` | |
| sum=$(( $sum + 5 )) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #swich case code | |
| echo "yes or no?" | |
| read answer | |
| case "$answer" in |