How to use substr to extract character between two semicolon?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use substr to extract character between two semicolon?
# 8  
Old 03-13-2015
It seems this will not give my desire output.
# 9  
Old 03-13-2015
can you print your desired output
# 10  
Old 03-13-2015
This my one row of my raw data set with 10 column:

Code:
gi|358485511|ref|NC_006088.3|         699545         .     A         G           122.03            PASS           AC=2;AF=1.00;AN=2;DP=6;Dels=0.00;FS=0.000;HaplotypeScore=0.0000;MLEAC=2;MLEAF=1.00;MQ=56.04;MQ0=0;QD=20.34                            GT:AD:PP:GQ:PL                  1/1:0,6:8:12:150,12,0

My desire output is:
Code:
gi|358485511|ref|NC_006088.3|   699545     A       G   1 1    8

To reminding, I have 300 file with a same data set structure.

Last edited by vgersh99; 03-13-2015 at 06:09 PM.. Reason: code tags, please!
# 11  
Old 03-13-2015
Code:
awk '{split($NF,a, "[/:,]"); print $1,$2,$4,$5, a[1], a[2], a[5]}' myFile

Next time please post what you input is EXACTLY and what would be the desired output.
# 12  
Old 03-13-2015
Is each of your 300 files one line? Or are there multiple lines in each file?

What operating system are you using?

What shell are you using?

Does the command:
Code:
ls *.work

succeed, or does it give you a diagnostic saying that your argument list is too long?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Substr with % - extract numbers only

# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.5 (Maipo) I have this script that will monitor filesystems and send me e-amil alerts. #! /bin/ksh DIST_LIST=monitor@...com WORKDIR=/home/monitor WARNLEVEL=90 MAIL_SUBJ="filesystems monitor on "$(hostname) ... (3 Replies)
Discussion started by: danielshell
3 Replies

2. Shell Programming and Scripting

Substr/Instr in shell script or extract part of text

Hi, I need to extract part of a text to two variables text is "PL/SQL procedure successfully completed. ERROR ----------------------------------------------------------------- Test Error Message PLUSVAR ---------- 1" I want "Test Error Message" in one variable and "1" in another variable.... (11 Replies)
Discussion started by: vedavrath
11 Replies

3. Shell Programming and Scripting

Replace semicolon within double quotes in a file with semicolon delimiter

Hello Team, Could you please help me with the below question? I have a file with the following properties 1) File Delimiter is ; 2) Text columns are within double quotes 3) Numeric columns will not have double quotes 4) File has total 6 columns Please see a sample record from file ... (3 Replies)
Discussion started by: sam99
3 Replies

4. Shell Programming and Scripting

Extract First character in Second column

Hi, I need to extract the first character of second column of my file. If the condition matches, then I need to print the 2nd and 3rd column as my output I tried below mentioned query but it was not working awk -F'|' '$2~/^5/' Sgn_group.txt File Name : Sgn_group.txt country... (2 Replies)
Discussion started by: suresh_target
2 Replies

5. UNIX for Dummies Questions & Answers

Delete a semicolon and numbers after a semicolon

I have this: ((9:0.010,(11:0.089,13:0.004)) and I would like this: ((A9,(A11,A13)) How do I delete the semi colon and the number (i.e. 0.010) after the semi colon? Also, how can I add the letter before the number that is NOT removed? Thank you in advance! ---------- Post updated... (4 Replies)
Discussion started by: MDeBiasse
4 Replies

6. Shell Programming and Scripting

awk extract certain digits from file with index substr

I would like to extract a digit from $0 starting 2,30 to 3,99 or 2.30 to 3.99 Can somebody fix this? awk --re-interval '{if($0 ~ /{1}{2}/) {print FILENAME, substr($0,index($0,/{1}{2}/) , 4)}}'input abcdefg sdlfkj 3,29 g. lasdfj alsdfjasl 2.86 gr. slkjds sldkd lskdjfsl sdfkj kdjlksj 3,34 g... (4 Replies)
Discussion started by: sdf
4 Replies

7. Shell Programming and Scripting

Extract semicolon separated delimiter

The log reads as follows. fname1;lname1;eid1;addr;pincode1; fname2;lname2;eid2;addr2;pincode2; fname3;lname3;eid3;addr3;pincode3; fname4;lname4;eid;addr4;pincode4; how do i extract only fname and save it in an array similarly for lname and so on i tried reading a file and cutting each... (5 Replies)
Discussion started by: vkca
5 Replies

8. Shell Programming and Scripting

Extract character from string

ps -eaf | grep “oracleTRLV (LOCAL=NO)” | while read ora_proc do echo $ora_proc done I would like to modify the above shell so that if character 13 and 14 equal "12" to do something. Sorry I'm new to shell:( (14 Replies)
Discussion started by: NicoMan
14 Replies

9. Shell Programming and Scripting

extract character + 1

Hi, I would like extract from a file a character or pattern after ( n + 1) a specific pattern (n) . ( i supposed with awk) how could i do ? Thanks in advance. (1 Reply)
Discussion started by: francis_tom
1 Replies

10. UNIX for Advanced & Expert Users

Extract a character

HI Guys, Have a Doubt...... I have a pattern "abcdef" and i need to extract the third character..ie(c) How to achieve it? (10 Replies)
Discussion started by: aajan
10 Replies
Login or Register to Ask a Question