Sponsored Content
Top Forums Shell Programming and Scripting print lines AFTER lines cointaining a regexp (or print every first and fourth line) Post 302435233 by kmkocot on Tuesday 6th of July 2010 09:34:25 PM
Old 07-06-2010
print lines AFTER lines cointaining a regexp (or print every first and fourth line)

Hi all,

This should be very easy but I can't figure it out...

I have a file that looks like this:
Code:
@SRR057408.1 FW8Y5CK02R652T length=34
AGCAGTGGTATCAACGCAGAGTAAGCAGTGGTAT
+SRR057408.1 FW8Y5CK02R652T length=34
FIIHFF6666?=:88@@@BBD:::?@ABBAAA>8
@SRR057408.2 FW8Y5CK02TBMHV length=52
CGTTGATACCACTGCTTACTCTGCGTTGATACCACTGCTTACTCTGCGTTGA
+SRR057408.2 FW8Y5CK02TBMHV length=52
FIIIIIFEDFCCEF<<<EFFFFGGGFFFFA:::AA@A<0004<889<422=7
@SRR057408.3 FW8Y5CK02R8Z08 length=72
CTCTGCGTTGATACCACTGCTTACTTCTGCGTTGATACCACTGCTTAACTCTGCGTTGGATACACTGCTTAC
+SRR057408.3 FW8Y5CK02R8Z08 length=72
FIIIIIIIIIIFFFFFDDFA:::D998@A??<844432125774----/158::85522443433=::91//
@SRR057408.4 FW8Y5CK02R76ED length=49
ATACCACTGCTTACTCTGCGTTGATACCACTGCTTACTCTGCGTTGATA
+SRR057408.4 FW8Y5CK02R76ED length=49
FIIIIIIIII@@@HIIIHFFFFHHFFFFFFFDDBBBBA=89444484//

I want to print every first and fourth line so that the output looks like this:
Code:
@SRR057408.1 FW8Y5CK02R652T length=34
FIIHFF6666?=:88@@@BBD:::?@ABBAAA>8
@SRR057408.2 FW8Y5CK02TBMHV length=52
FIIIIIFEDFCCEF<<<EFFFFGGGFFFFA:::AA@A<0004<889<422=7
@SRR057408.3 FW8Y5CK02R8Z08 length=72
FIIIIIIIIIIFFFFFDDFA:::D998@A??<844432125774----/158::85522443433=::91//
@SRR057408.4 FW8Y5CK02R76ED length=49
FIIIIIIIII@@@HIIIHFFFFHHFFFFFFFDDBBBBA=89444484//

No matter what I try along the lines of
Code:
sed -n '1,${p;n;n}'

, I can't get it to work. I'm sure there is an easy to specify the printing of every first and fourth line only but for future reference, how would I specify "print lines after lines beginning with a plus sign?"

Thanks,
Kevin

---------- Post updated at 08:34 PM ---------- Previous update was at 08:14 PM ----------

Well I finally figured this much out:
Code:
sed -n '1~4p;4~4p' demo.fastq

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

print the line immediately after a regexp; but regexp is a sentence

Good Day, Im new to scripting especially awk and sed. I just would like to ask help from you guys about a sed command that prints the line immediately after a regexp, but not the line containing the regexp. sed -n '/regexp/{n;p;}' filename What if my regexp is 3 word or a sentence. Im... (3 Replies)
Discussion started by: ownins
3 Replies

2. UNIX for Dummies Questions & Answers

grep N lines after match and then print them on 1 line each

Hello I have a silly question. I need to grep a match in text file and then print 5 lines after it. grep -A 5 .... do it. OK The next thing I can not handle is I need each output to be on 1 line match line2 line3 line4 line5 match line2 line3 line4 line5 etc.. I will really... (10 Replies)
Discussion started by: alekkz
10 Replies

3. Shell Programming and Scripting

print 2 lines above regexp

I am on a Solaris 10 x86 system sample code before3 before2 before1 group after1 after2 after3 I want to grab the second line above my regexp regexp=group I want to grab ONLY the before2 line I have numerous sed and awk ways of grabbing X line below the regexp, but no luck... (1 Reply)
Discussion started by: snoman1
1 Replies

4. Shell Programming and Scripting

print first few lines, then apply regex on a specific column to print results.

abc.dat tty cpu tin tout us sy wt id 0 0 7 3 19 71 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device 0.0 133.2 0.0 682.9 0.0 1.0 0.0 7.2 0 79 c1t0d0 0.2 180.4 0.1 5471.2 3.0 2.8 16.4 15.6 15 52 aaaaaa1-xx I want to skip first 5 line... (4 Replies)
Discussion started by: kchinnam
4 Replies

5. Shell Programming and Scripting

print lines between line number

Hi, Anyone help me to print the lines from the flat file between 879th line number and 1424th line number. The 879 and 1424 should be passed as input to the shell script(It should be dynamic). Can any one give me using sed or awk? I tried using read, and print the lines..Its taking too... (3 Replies)
Discussion started by: senthil_is
3 Replies

6. Shell Programming and Scripting

Print lines between a regExp & a blank line

Hi, I have a file, say files_list, as below (o/p of ls -R cmd) $ cat files_list /remote/dir/path/to/file: sub-dir1 sub-dir2 sub-dir3 ... /remote/dir/path/to/file/sub-dir1: remote_file1.csv.tgz <blank line 1> /remote/dir/path/to/file/sub-dir2: remote_file2.csv.tgz <blank... (3 Replies)
Discussion started by: dips_ag
3 Replies

7. Shell Programming and Scripting

sed print first line before regexp and all lines after

Hi All I'm trying to extract the line just above a regexp and all lines after this. I'm currently doing this in two steps sed -n -e "/^+---/{g;p;}" -e h oldfile.txt > modified.txt sed -e "1,/^+---/d" -e "/^$/d" oldfile.txt >>modified.txt Sample sometext will be here sometext will be... (3 Replies)
Discussion started by: Celvin VK
3 Replies

8. Shell Programming and Scripting

Print the first line for each multiple lines

Hi all, i need help to extract each first line from multiple lines occurrences based on different patterns (name) starting from the fourth lines like follows:- // header 1 header 2 header 3 // no acc name score rank //... (2 Replies)
Discussion started by: redse171
2 Replies

9. Shell Programming and Scripting

Print multiple lines on one line

Hi All, I have a file looks like: rst:singh:99.0.20-X86 2 rst:ACSI_SIN_SERVICES rst:singh:99.0.20-X86 2 rst:ACSI_BISI want to wrap 3rd col in one line and add variable value at start and ending of line and I wrote command: cat file | awk '{print $3}' | xargs > command.txt sed -e... (1 Reply)
Discussion started by: rakeshtomar82
1 Replies

10. UNIX for Beginners Questions & Answers

Print number of lines for files in directory, also print number of unique lines

I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with: wc -l *|sort 15263 Image.txt 16401 reference.txt 40459 richtexteditor.txt How can I also print the number of unique lines in each file? 15263 1401 Image.txt 16401... (15 Replies)
Discussion started by: spacegoose
15 Replies
LCG_LIMITS(4)							   File Formats 						     LCG_LIMITS(4)

NAME
Castor_limits - LCG internal limits SYNOPSIS
#include <Castor_limits.h> DESCRIPTION
The Castor_limits.h header file contains all the common limits that all LCG subpackages have to respect. These are: CA_MAXACLENTRIES maximum number of ACL entries for a file/dir Default value: 300 CA_MAXCLASNAMELEN maximum length for a fileclass name Default value: 15 CA_MAXCOMMENTLEN maximum length for user comments in metadata Default value: 255 CA_MAXDENFIELDS maximum number of density values in devinfo Default value: 8 CA_MAXDENLEN maximum length for a alphanumeric density Default value: 8 CA_MAXDGNLEN maximum length for a device group name Default value: 6 CA_MAXDPMTOKENLEN maximum length for a Disk Pool Manager token Default value: 36 CA_MAXDVNLEN maximum length for a device name Default value: 63 CA_MAXDVTLEN maximum length for a device type Default value: 8 CA_MAXFIDLEN maximum length for a fid (DSN) Default value: 17 CA_MAXFSEQLEN maximum length for a fseq string Default value: 14 CA_MAXGID maximum value for gid Default value: 0x7FFFFFFF CA_MAXGRPNAMELEN maximum length for a group name Default value: 2 CA_MAXGUIDLEN maximum length for a guid Default value: 36 CA_MAXHOSTNAMELEN maximum length for a hostname Default value: 63 CA_MAXLBLTYPLEN maximum length for a label type Default value: 3 CA_MAXLINELEN maximum length for a line in a log Default value: 1023 CA_MAXMANUFLEN maximum length for a cartridge manufacturer Default value: 12 CA_MAXMLLEN maximum length for a cartridge media_letter Default value: 1 CA_MAXMODELLEN maximum length for a cartridge model Default value: 6 CA_MAXNAMELEN maximum length for a pathname component Default value: 255 CA_MAXNBDRIVES maximum number of tape drives per server Default value: 32 CA_MAXPATHLEN maximum length for a pathname Default value: 1023 CA_MAXPOLICYLEN maximum length for a policy name Default value: 15 CA_MAXPOOLNAMELEN maximum length for a pool name Default value: 15 CA_MAXPROTOLEN maximum length for a protocol name Default value: 7 CA_MAXRBTNAMELEN maximum length for a robot name Default value: 17 CA_MAXRECFMLEN maximum length for a record format Default value: 3 CA_MAXREGEXPLEN maximum length for a regular expression Default value: 63 CA_MAXSFNLEN maximum length for a replica Default value: 1103 CA_MAXSHORTHOSTLEN maximum length for a hostname without domain Default value: 10 CA_MAXSNLEN maximum length for a cartridge serial nb Default value: 24 CA_MAXSTGRIDLEN maximum length for a stager full request id (must be >= nb digits in CA_MAXSTGREQID + CA_MAXHOSTNAMELEN + 8) Default value: 77 CA_MAXSTGREQID maximum value for a stager request id Default value: 999999 CA_MAXUID maximum value for uid Default value: 0x7FFFFFFF CA_MAXSYMLINKS maximum number of symbolic links Default value: 5 CA_MAXTAGLEN maximum length for a volume tag Default value: 255 CA_MAXTAPELIBLEN maximum length for a tape library name Default value: 8 CA_MAXUNMLEN maximum length for a drive name Default value: 8 CA_MAXUSRNAMELEN maximum length for a login name Default value: 14 CA_MAXVIDLEN maximum length for a VID Default value: 6 CA_MAXVSNLEN maximum length for a VSN Default value: 6 AUTHOR
LCG Grid Deployment Team LCG
$Date: 2007/02/03 11:16:45 $ LCG_LIMITS(4)
All times are GMT -4. The time now is 06:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy