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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am having problems with my script running correctly using Bash and what I want to do is this....
I have 3 sub-directories called /opt/log/NYclient, /opt/log/Patchlog and /opt/log/Systemlog. In each directory, there is a .log file. Now what I want to do is to cut the 2nd field and have the output going to files NYclient.log, Patchlog.log and Systemlog.log. Here is my script that seems to be erroring:
for d in /opt/log/*; do
cut -d "," -f2 "$d"/*.dat > "$dat"
The files are located in /opt/log/NYclient/NYclient.log and the others follow the same. The script need to be dynamic as if I need to add additional.
Any help would be appreciated.
Last edited by Codfather1; 09-24-2015 at 03:35 PM.
Distribution: Linux From Scratch, Slackware64, Partedmagic
To start please use code tags when posting code, second you are not setting the 'dat' variable at the end of the 'cut' line, so redirection isn't going to work, also can you include examples of the log files, if they are too big just trim them to give a reasonable sample of the file.
Here is my log file that I'm cutting. I'm using the cut -d "," -f2 and that works if I just output it to a plain file but not what I'm trying to do. The $dat is not defined and any help would be appreciated. I'm new to the forum and this is my first posted. I'll try to keep in the correct format.
Well I replaced my basename with your changes and it worked great. The only I will do is create separate directories and dump those files in the proper directories which I can do. Thank you very much as this was a learning experience. But I have one question: