If you are working with large number of servers and services in linux this might be useful to you. Not only in System Administration but also this simple few lines can be used in different kind of situations. In my case I am going to use this shell to retrieve names of multiple git repos and create new github repos them using HUB.
Let's Start!
First create a text file and include whatever you need to parse LINE BY LINE
ex:
sudo vim input.txt
THIS LINE 1
THIS LINE 2
THIS LINE 3
THIS LINE 2
THIS LINE 3
Then Save it!
And then Create the shell file
sudo vim line.sh
file=/path/to/text/file
while IFS= read
echo "$line"
done < "$file"
and then save it and make sure to set chmod as +x :-)
while IFS= read
-r line || [ -n "$line" ]
doecho "$line"
done < "$file"
and then save it and make sure to set chmod as +x :-)
is that it? yes!
you can do lot of cool things from this simple code. Don't forget to mention them on the comment section
and also the next post will be about usage of this shell with HUB. Thanks!
No comments:
Post a Comment