Last active
December 27, 2021 11:24
-
-
Save mukeshgurpude/fee646bc4e741625c9d3ad52c3ae6db8 to your computer and use it in GitHub Desktop.
OS-Lab Exercises
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
| # iterate through jpg files in current directory | |
| # and rename them to start with today's date | |
| for file in $( ls *.jpg ) | |
| do | |
| mv $file $(date +%F)-$file | |
| done |
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
| # Delete the zero sized files in the current directory | |
| find . -type f -size 0 -exec rm {} \; |
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
| # Remove duplicate lines from a file | |
| #- Line numbers file | |
| # Sort the file | |
| # Remove duplicates | |
| # sort according to line numbers | |
| # Remove line numbers | |
| file=$1; | |
| cat -n $file > .a.tmp | |
| sort -k 2 .a.tmp > .b.tmp | |
| uniq -f 1 .b.tmp > .a.tmp | |
| sort -n .a.tmp > .b.tmp | |
| cut -f 2 .b.tmp > .a.tmp | |
| echo "The file $file has been cleaned" | |
| cat .a.tmp > $file | |
| rm .a.tmp .b.tmp | |
| echo "Cleaned file is: " | |
| cat $file |
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
| Content |
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
| duplicate | |
| lines | |
| here | |
| lines | |
| duplicate | |
| line | |
| here | |
| with | |
| duplicate | |
| lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment