Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
03-09-2011, 07:25 AM
|
#1
|
LQ Newbie
Registered: Feb 2010
Posts: 18
Rep:
|
extracting columns with awk
hi
why does this only use column 3?
awk '{print $3 $6 $7 >> "area.plt" }' mol.are
thnx.
g.
|
|
|
03-09-2011, 07:29 AM
|
#2
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
How are we supposed to know what .plt and .are files are.
Also, the >> "area.plt" part should be outside the awk command. Otherwise we can't tell you what the output would look like without a sample of the input.
|
|
|
03-09-2011, 07:39 AM
|
#3
|
Senior Member
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339
|
Quote:
Originally Posted by jschiwal
Also, the >> "area.plt" part should be outside the awk command.
|
According to man awk it's allowed to be used as option to a print command. Mabye it's a gawk extension.
But of course, w/o knowing the input we can't say much.
|
|
|
03-09-2011, 07:44 AM
|
#4
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Thanks Reuti. I didn't know that. It does look strange, and I don't see why you would unless you are running an actual awk script.
|
|
|
03-09-2011, 08:14 AM
|
#5
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
Quote:
Originally Posted by jschiwal
I don't see why you would unless you are running an actual awk script.
|
Actually it is useful only when you have multiple redirections (to different files) inside the awk script or when the file name is built dinamycally under certain conditions.
@gav251: please follow the advice in the previous posts and show us the content (or just a sample) of the input file. Don't forget to embed it in CODE tags to preserve spacing and tabs (since they might be important to solve the puzzle). To use CODE tags, either put [CODE] and [/CODE] around the text or switch to advanced mode and press the # button.
|
|
|
03-10-2011, 05:52 AM
|
#6
|
LQ Newbie
Registered: Feb 2010
Posts: 18
Original Poster
Rep:
|
The .plt file is a new file, > would be ok. .mol file is a large file containing mathematical data about a proteins geometry. I didn't post it since the data is irrelevant. I just need to redirect columns 3, 6 and 7. Sorry for the ambiguity.
g.
|
|
|
03-10-2011, 06:24 AM
|
#7
|
Senior Member
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339
|
Quote:
Originally Posted by gav251
I didn't post it since the data is irrelevant. I just need to redirect columns 3, 6 and 7.
|
Obviously it's not irrelevant, otherwise your awk command would work. So showing one line of the input and the result which is produced by this line would allow to investigate the behavior.
|
|
|
03-10-2011, 08:40 AM
|
#8
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
Quote:
Originally Posted by Reuti
Obviously it's not irrelevant, otherwise your awk command would work. So showing one line of the input and the result which is produced by this line would allow to investigate the behavior.
|
The same from me. The result from such a simple code should be obvious, so most likely the problem resides in the input format: separators, hidden characters and so on. Please post a line of input, the corresponding output (as suggested above) plus the output of the following:
Code:
head -3 file.mol | od -c
and please use CODE tags.
|
|
|
All times are GMT -5. The time now is 03:03 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|