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 have a very large file with column data that doesn't have any headers it is space seperated, sometime several spaces, and it's too big to open in a text editor. I'll call it C.dat. So I do something like
Code:
head -300 C.dat > littleC.dat
and I can see some of the file contents.
I have another file with row formated text information, like 700 or so rows. I'll call it R.txt. The R.txt file has the "field" information that goes with the columns in C.dat. The R.txt file looks like this:
so the row of information that I need to use from R.txt is FIELD_NAME, and what I'd like to do is strip out each FIELD_NAME string and write it to an another output file along with an index number. I need the index number for another tool that filters by column index.
each "block" of field info is indexed correctly down the R.txt file even though the FIELD_COLUMN numbers are not, so I don't think that I really care about the FIELD_COLUMN numbers, and I can just go down the R.txt file using only the FIELD_NAME string and placing it sequentially in line in the new output file.
here's what I'd like the file to look like:
Code:
1 header_info_a
2 header_info_b
3 header_info_c
etc.
so this kinda somewhat works, but not really. I don't know how to create the index_counter and the results of sed give more than just the FIELD_NAME string which I don't understand becasue my grep only has the FIELD_NAME string.
Thanks ! You can mark the question as SOLVED (Under Thread Tools option on the top of the page).
Quote:
...is that called "nesting" I had no idea awk could do that?
It's called process substitution, which means insert output of a command in another.
Quote:
...why did you use $3, I'm not sure what that means, is it different that $1
$ is nothing but represents variables. Well, a simple answer to this question will lead you to get confused, so better first go through Awk lessions here.
For your knowledge you can read or learn about process substitution, but your question was not all about it.
Well, as per documents..
Quote:
Process substitution feeds the output of a process (or processes) into the stdin of another process.
So I feel, you should once go through following guides, for clear understanding:
1. Process Substitution
2. Advance Bash Scripting Guide
These guides are treasure of knowledge. You'll learn many more techniques as well.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.