[SOLVED] Parsing delimited file and variable scripting.
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I did some searches and after a few hours was able to get what I needed. What I didn't find was a fully encompased means of what I'm used to in the windows world in working with delimted files. Hopefully this is helpful to others and if there is something better or leaner way, even better.
We have an issue where managing printers, just viewing on RHEL w/ sys-conf-prtr we lose any number of, up to ~30 printers from lpadmin. Rather than stare and compare to find the missing ones, I wanted to make an intuitive script. This is what I came up with.
Code:
#!/bin/sh
while IFS="," read Prntr IP; do
lpstat -a | grep $Prntr > /dev/null 2>&1
if test $? != "0"; then
lpadmin -p $Prntr -u allow:all -v "socket://$IP:9100" -E
echo " ..... $Prntr was installed"
else
echo "Printer $Prntr is installed"
fi
done < prntrs.lst | more +2
Here's the output that I get:
Printer test1 is installed
Printer test2 is installed
Printer test3 is installed
Printer test4 is installed
Printer test5 is installed
..... test8 was installed
..... test9 was installed
Right on MensaWater. I also read yesterday that there is a better place for it. Not sure if it can be moved...
Was hoping there would be some additional information on it, I'm new to Linux and going through the learning curve of the different shells and scripting.
If so, I'd suggest you put in the move request, and have this moved to the /Programming forum, as that would be, in my opinion, the best place for this. If you think another forum would be better, just ask, and a moderator will figure out if it belongs there, or where it would be better located.
To ask for a thread to be moved (or for any other thread/post-related request), just click the REPORT button on your first post in the thread, and send a note to us; we'll take care of it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.