This is continuation of my previous articles .. Please don't miss them :- Bash Simple Tricks Bash Simple Tricks (continuation) Again I am following a question – solution approach to demonstrate my scripts.. Scripts How to 'cat'(print) all the files in a folder Solution :- Code: #!/bin/bash cat `ls` ls output :- Code: aneesh@aneesh-laptop:~/articles/Bash$ ls char2.sh displayA.sh endZ.sh file1 ls.sh vovelFile.sh Running :- Code: aneesh@aneesh-laptop:~/articles/Bash$ ./ls.sh #!/bin/bash cat $1 | grep '..[eE]' | wc -l #!/bin/bash cat $1 | grep ^[aA] | wc -l #!/bin/bash cat $1 | grep [z]$ | wc -l aaessss aaaesss aaaaaaaa lionaneesh ssssssssss #!/bin/bash cat `ls` #!/bin/bash ls | grep ^[aeiouAEIOU] | wc -l cat(Print) all the .txt files in a folder Solution :- Code: #!/bin/bash cat `ls | grep .txt` ls output :- Code: aneesh@aneesh-laptop:~/articles/Bash$ ls char2.sh endZ.sh ls.sh txt2.txt vovelFile.sh displayA.sh file1 txt1.txt txt.sh Using :- Code: aneesh@aneesh-laptop:~/articles/Bash$ sh txt.sh WOOOOOOWWWWWW!!! Its file no 1 named txt1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Hello !!!!!! Hi Wassup This is file no 2 named txt2 Write a bash script to display todays date and time.. Code: aneesh@aneesh-laptop:~/articles/Bash$ cat date.sh #!/bin/bash echo "Today is `date`" Using :- Code: aneesh@aneesh-laptop:~/articles/Bash$ chmod +x date.sh aneesh@aneesh-laptop:~/articles/Bash$ ./date.sh Today is Tue Feb 15 22:23:57 IST 2011 Write a bash script to output the date and time in audio format(speak) Code: #!/bin/bash espeak "Today is `date`" Using :- Code: aneesh@aneesh-laptop:~/articles/Bash$ chmod +x date2.sh aneesh@aneesh-laptop:~/articles/Bash$ ./date2.sh Write a bash script to maximize all the windows opened after a specified no of seconds.. Solution :- Code: #!/bin/bash sleep $1 maximus Using :- Code: aneesh@aneesh-laptop:~/articles/Bash$ chmod +x maximise.sh aneesh@aneesh-laptop:~/articles/Bash$ ./maximise.sh 2 How to download youtube videos with bash ? Code: #!/bin/bash youtube-dl $1 Using :- Code: aneesh@aneesh-laptop:~/articles/Bash$ chmod +x youtube.sh aneesh@aneesh-laptop:~/articles/Bash$ ./youtube.sh http://www.youtube.com/watch?v=m8Dd7rjmEW4
If you are viewing this article leave a comment whether you like it or not...Or what you want more from the article...Etc..etc...