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.
Hi !! Have a look please if anyone can help me (I'm indeed a new bash learner). I've a file let's call it 'test.txt' which contain the followings (more precisely its an alignment file)
now how can i get 'n'th column starting from a specif pattern such as 'RRR'(as for e.g. from the above text file, ) ('n'th column before this pattern or after this pattern)
thanks in advance
Last edited by asrshell; 01-28-2013 at 04:24 PM.
Reason: i didn't find the text as i typed
print 'n'th column (before or after) starting from a pattern
Thanks both of you kbp and shivaa for answering
shivaa: your code isn't producing what i want. please consider each character as column (anyway your code help me to solve some of my other problems).
Kbp: cheers!! your code is working but only 'after' the given pattern (i.e. it's generating desired column from the 'right' side of the pattern).
1. How can it work 'before' the pattern also (i.e. from the 'left' side of the pattern)?
2. Does it possible to print the output with line header (in that e.g.A-4, A-5, A-6 etc. these are line header)
(additional query to all)
Let's i have a file called 'test.txt' contains as below where A-1 , A-2, A-3 etc are line headers. (there is always same space after each line header. there is also space between paragraph.)
3. Is it possible to get 'n' th column starting from a pattern to lines/paragraph (before or after the pattern) where the the pattern is absent. Let's consider above e.g.
How can i print 'n'th column from paragraph 1 or 3 starting count from a pattern 'RRR' (which is present in the 2nd and 4th paragraph) for e.g. 18th(ignoring line header and white space) column starting from the left side of the 2nd 'RRR' pattern or starting from the right side of the 1st 'RRR' pattern?
it would be nice if the output prints with corresponding line header. so briefly i would be happy if i got a output like this
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.