Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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 am doing some operation on all partitions (other then root and default ones).. here is what I cooked up, but don't look nice. Any help in doing this in more professional manner!
Last edited by Fracker; 07-10-2012 at 03:37 AM.
Reason: Change Quote to Code
First of all, please use ***[code][/code] tags*** around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.
You have a Useless Use Of Cat and Grep, as well as unnecessary multiple instances of grep, even if you did need it (check out the -e option). The temp file and loop aren't necessary either.
A single awk command (it's a full text processing language that can completely replace grep and sed) with proper regex matching and formatted print statement can do it all. This command exactly replicates the above:
I need loop or atleast a shell where I can play with normal shell commands. Awk don't have many commands. That's why I use while loop for this task.
Please try and explain further so we might assist? Awk is a very full featured command / language and I would be surprised if what you need to accomplish cannot be handled.
Please try and explain further so we might assist? Awk is a very full featured command / language and I would be surprised if what you need to accomplish cannot be handled.
I need to assign single value to a variable and after that call a function, which will do some tasks based on this variable.
If you want to run arbitrary commands on the files, then you can still feed the raw output into a loop. For maximum safety regarding possible unusual filename characters, use a null separator between them ( use printf and "\0" in awk ).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.