Remove 1st character in periodic lines


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Remove 1st character in periodic lines
# 1  
Old 10-28-2011
Question Remove 1st character in periodic lines

Hi,
I have a file that looks like this, the unity of information is composed of four lines, and these extends for millions.

Quote:
@853_103_1883
TCACTACTACGACACTACTTCTGTCGACTCCTGTATAGTAG
+
78/)3*=//+9=*(<6@,73&8&*&/5&4%,7%0%.Smilie7&
@853_106_929
TCACTACTTGCTTGTTTTCGCTCCCCTTCCATGCTGCTGCG
+
9<(1/37=)6;?7,49>37'57:3388+7&.55705;<7*
@853_108_1709
TCACTACGAAGCTTTGGCCTTCAACGCCTCCATGCTGCTGC
+
<345=+;7<5&8=A>4>;9=16A=0%>87:3<?:<,@8==
@853_112_748
TCACTACCTGTCGCACCAGCGGCGCGATAATCGTATGCCGT
+
A;.85>8',);9%->;34.<@@0'@4%<0)>?::?%94:+
My objective is to remove the highligthed "T".

Quote:
@853_103_1883
CACTACTACGACACTACTTCTGTCGACTCCTGTATAGTAG
+
78/)3*=//+9=*(<6@,73&8&*&/5&4%,7%0%.Smilie7&
@853_106_929
CACTACTTGCTTGTTTTCGCTCCCCTTCCATGCTGCTGCG
+
9<(1/37=)6;?7,49>37'57:3388+7&.55705;<7*
@853_108_1709
CACTACGAAGCTTTGGCCTTCAACGCCTCCATGCTGCTGC
+
<345=+;7<5&8=A>4>;9=16A=0%>87:3<?:<,@8==
@853_112_748
CACTACCTGTCGCACCAGCGGCGCGATAATCGTATGCCGT
+
A;.85>8',);9%->;34.<@@0'@4%<0)>?::?%94:+
How to attack this? This character is always constant in type "T" and position "1st" but the rest of the line is variable. The positons of the lines are periodics of every 2nd, 6st, 10th... lines, and upstream and downstream lines always start with "@" and "+". The fourth line might contain a "T" in the 1st position which I don't want to remove

Iknow the basics of unix commands.

Cheers!
# 2  
Old 10-28-2011
Code:
$ sed 's,^T,,g' infile

This User Gave Thanks to jayan_jay For This Post:
# 3  
Old 10-28-2011
Quote:
Originally Posted by jayan_jay
Code:
$ sed 's,^T,,g' infile

Perfect!
's,^T,,g' ---> Going to look who is who and doing what...

cheers!
# 4  
Old 10-28-2011
sed will remove the alphabet T if it is the first character in a file ..

Sed basics .. http://sed.sourceforge.net/sed1line.txt
# 5  
Old 10-28-2011
Quote:
Originally Posted by jayan_jay
sed will remove the alphabet T if it is the first character in a file ..
But it will remove if is 1st character in every line? I might have "T" in 4th, 8th, 12th,... that I don't want to remove. Either way if that's the case, further upstream I will have a error warning.
# 6  
Old 10-28-2011
So what is your expected output based on your input file ..
# 7  
Old 10-28-2011
You can supply an address (e.g. a line number) in sed commands to restrict the lines it changes.

For example, sed '2 s,^T,,g' would only operate on line 2, sed '2~4 s,^T,,g ' is line 2 and every 4th line after that.
This User Gave Thanks to CarloM For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Remove newline character from column spread over multiple lines in a file

Hi, I came across one issue recently where output from one of the columns of the table from where i am creating input file has newline characters hence, record in the file is spread over multiple lines. Fields in the file are separated by pipe (|) delimiter. As header will never have newline... (4 Replies)
Discussion started by: Prathmesh
4 Replies

2. UNIX for Beginners Questions & Answers

Remove lines ending with a certain character

I have a file of a content like this: abc_bla -def 800 abc_bla -def 802 abc_bla -def 804 abc_bla -def 806 abc_bla -def 808 abc_bla -def 810 abc_bla -def 812 abc_bla -def 814 ... abc_bla -def 898 abc_bla -def 900 abc_bla -def 902 abc_bla -def 904 ... abc_bla -def 990 abc_bla -def... (7 Replies)
Discussion started by: maya3
7 Replies

3. Shell Programming and Scripting

How to remove newline character if it is the only character in the entire file.?

I have a file which comes every day and the file data look's as below. Vi abc.txt a|b|c|d\n a|g|h|j\n Some times we receive the file with only a new line character in the file like vi abc.txt \n (8 Replies)
Discussion started by: rak Kundra
8 Replies

4. Shell Programming and Scripting

awk to remove lines that do not start with digit and combine line or lines

I have been searching and trying to come up with an awk that will perform the following on a converted text file (original is a pdf). 1. Since the first two lines are (begin with) text they are removed 2. if $1 is a number then all text is merged (combined) into one line until the next... (3 Replies)
Discussion started by: cmccabe
3 Replies

5. Shell Programming and Scripting

Remove previous line if next & previous lines have same 4th character.

I want to remove commands having no output. In below text file. bash-3.2$ cat abc_do_it.txt grpg10so>show trunk group all status grpg11so>show trunk group all status grpg12so>show trunk group all status GCPKNYAIGT73IMO 1440 1345 0 0 94 0 0 INSERVICE 93% 0%... (4 Replies)
Discussion started by: Raza Ali
4 Replies

6. Shell Programming and Scripting

Execution problem ---to remove the lines which starts with one type of character

Hi, I have one file, I need to check if file exist or not and then remove the lines which starts with ? My file1.out data is some thing abcabcppp xyzxyzpqr ????????? ????????? Output should be in test.out abcabcppp xyzxyzpqr I am getting the output as below but the File does not exist... (4 Replies)
Discussion started by: Ramyajiguru1
4 Replies

7. UNIX for Advanced & Expert Users

Remove lines if the first character is "|"

Hi. I have a huge file (350 million lines). I need to delete all lines in it that: 1. Begin with a pipe character -- '|' 2. Or have less than 5 pipe characters in the line Have been searching for some SED/AWK help for this (which is faster btw on such a ginormous file?) but only... (7 Replies)
Discussion started by: pkiula
7 Replies

8. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

9. UNIX for Advanced & Expert Users

remove lines from file where > 13 occurrences of character

I have a '~' delimited file of 6 - 7 million rows. Each row should contain 13 columns delimited by 12 ~'s. Where there are 13 tildes, the row needs to be removed. Each row contains alphanumeric data and occasionally a ~ ends up in a descriptive field and therefore acts as a delimiter, resulting... (7 Replies)
Discussion started by: kpd
7 Replies

10. Shell Programming and Scripting

How do I remove lines that have more than one of a certain character in them?

I have a file with a few thousand lines and I'd like to remove all the lines that have more than 1 asterik (the * character) in it. So if it has 2 or more in a single line, I'd like the line removed (double d command in vi) (12 Replies)
Discussion started by: guitarscn
12 Replies
Login or Register to Ask a Question