Extract a character


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Extract a character
# 8  
Old 08-18-2007
[QUOTE=bishweshwar;302132636][QUOTE=matrixmadhan;302132635]
Quote:
Originally Posted by bishweshwar


the first 2 characters are specified as ^..
the third character is mentioned as \(.\)
and the remaining characters starting from 4th character to till the end of the string is blocked by .*

Is there any other way...even...the expression .* how it blocks the rest of characters.
.* - refers to greedy match as you might know

since the first 3 characters are consumed as ( 2 characters and a third character ) all the remaining characters in the form .* would be blocked.

Does that answer your question ?
# 9  
Old 08-20-2007
THanks Guys!!!!!!!!!!!!!!!!!!!!!!!!!
# 10  
Old 08-20-2007
if you use bash
Code:
# var="abcdef"
# echo ${var:2:1}
c

# 11  
Old 08-20-2007
With zsh:

Code:
% var="abcdef"
% print ${var[3]}
c

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to extract every 6-th character in a line?

Hi, I have a file consist of 25000 lines and each line has 2 columns 1 column with 6 numeric characters and 2nd one with 45000 numeric characters (not delimited). I want to take every 7th character form the 2nd column, keeping the first column. I made it in several steps but it run for 7 hours to... (7 Replies)
Discussion started by: SANDO
7 Replies

2. Shell Programming and Scripting

Extract all first numeric character from a string

Hello, I have a file of strings a below:- 4358RYFHD9845 28/COC/UYF984 9834URD 98HJDU I need to extract all the first numeric character of every sting as follows:- 4358 28 9834 thanks to suggest ASAP Regards, Jasi Use code tags, thanks. (7 Replies)
Discussion started by: jassi10781
7 Replies

3. Shell Programming and Scripting

How to use substr to extract character between two semicolon?

Dear folks Hello I have a data set which one of the column of this data set are string and I want to extract numbers which is between two ":". However, I know the substr command which will do this operation but my problem is the numbers between two ":" have different digits. this will make my... (11 Replies)
Discussion started by: sajmar
11 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. Shell Programming and Scripting

Extract text between two character positions

Greetings. I need to extract text between two character positions, e.g: all text between character 4921 and 6534. The text blocks are FASTA-format sequence of whole chromosomes, so basically a million A, T, G, C, combinations. E.g: >Chr_1 ACCTGTTCAACTCTCAGGACTCTCAGGTCAACTCTCAG... (3 Replies)
Discussion started by: Twinklefingers
3 Replies

6. Shell Programming and Scripting

Extract a character specifying position

hi , i am having a file Full_ARTMAS_20110510152425.xml in my local directory. i wanted to extract the character at the 35143546 th position at line 1 of this file.Can any body help me how to do it??? regards Anjali (2 Replies)
Discussion started by: angel12345
2 Replies

7. 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

8. Shell Programming and Scripting

Extract the last character of a string

How can I extract the last character of a string (withou knowing how many characters are in that string ! ) (8 Replies)
Discussion started by: annelisa
8 Replies

9. Shell Programming and Scripting

How to extract first column with a specific character

Hi All, Below is the sample data of my files: O|A|571000689|D|S|PNH|S|SI sadm|ibscml1x| I|A|571000689|P|S|PNH|S|SI sadm|ibscml1x| O|A|571000689|V|S|PNH|S|SI sadm|ibscml1x| S|C|CAM|D|S|PNH|R|ZOA|2004 bscml1x| ... (3 Replies)
Discussion started by: selamba_warrior
3 Replies

10. 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
Login or Register to Ask a Question