Sponsored Content
Top Forums Shell Programming and Scripting Find last occurrence of a character in a string Post 302814757 by Don Cragun on Thursday 30th of May 2013 07:01:01 AM
Old 05-30-2013
Assuming you're using a standards conforming shell (such as bash or ksh), this will also work:
Code:
str="aa-bbb-cccc-ddd-ee"
end=${str##*-}
echo "Last - is in column $((${#str} - ${#end}))"

and only uses shell built-ins.

With your sample string, it produces:
Code:
Last - is in column 16

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find and replace character in a string

Hi all, My problem is the following: I've a script that must list all files in a directory and write this information in a text file. I've tried to get the list through ls command and then write it using msgecho msgecho "`ls $PATH_APS_JOB_ORA`" This works good but the created string... (7 Replies)
Discussion started by: callimaco0082
7 Replies

2. Shell Programming and Scripting

To find a character immediately following a specified String

Hello, I have a UNIX file in which data is like this -- ISA*00* *00* *01*006415160 *01*137361242 ... (3 Replies)
Discussion started by: The Observer
3 Replies

3. Shell Programming and Scripting

Sed to print a string until the second occurrence of a character

Hi, I am totally new to shell scripting. I have a String "c:\working\html\index.txt.12-12-2009.bkp" I want to check if the string has more than one "." character. If it does I would like to retrieve only "c:\working\html\index.txt" i.e, discard the second occurrence of "." and the rest of the... (7 Replies)
Discussion started by: imr
7 Replies

4. Shell Programming and Scripting

Find the middle character from a string using sed

Input: qwertmyuiop It should print "m". What's the command to do this with sed? (6 Replies)
Discussion started by: cola
6 Replies

5. Shell Programming and Scripting

find string nth occurrence in file and print line number

Hi I have requirement to find nth occurrence in a file and capture data from with in lines (between lines) Data in File. <QUOTE> <SESSION> <ATTRIBUTE NAME='Parameter Filename' VALUE='file1.parm'/> <ATTRIBUTE NAME='Service Name' VALUE='None'/> </SESSION> <SESSION> <ATTRIBUTE... (6 Replies)
Discussion started by: tmalik79
6 Replies

6. Shell Programming and Scripting

Find string in a file and append character

Hi Experts, Is there a way to find a string in a file then append a character to that string then save the file or save to another file. Here is an example. >cat test.txt NULL NULL NULL 9,800.00 NULL 1,234,567.01 I want to find all NON NULL String and add a dollar sign to those... (9 Replies)
Discussion started by: brichigo
9 Replies

7. Shell Programming and Scripting

Remove last occurrence of character (_) and rest of the string in UNIX (sed)

Hi I need help on this ..!! Input : xx_abc_regA xx_def_regB xx_qwe_regC Now i required the output as the below abc def qwe Need to remove last occurrence of character (_) and rest of the string in Unix (sed). Thanks in Advance ..!!! -Nallachand (3 Replies)
Discussion started by: Nallachand
3 Replies

8. Shell Programming and Scripting

Find a string occurrence if twice in a line

Hello All, I want to check if a delimiter is existing twice in a line of a text file. Suppose flat file is like this 234 | 123 123 | 345 456 | 563 | 234 | 548 So the the 3rd line has two delimiters, How can we find the lines in such a file having more then one delimiters I tried... (5 Replies)
Discussion started by: nnani
5 Replies

9. Shell Programming and Scripting

To find nth position of character in string

Hi guyz i want to know nth position of character in string. For ex. var="UK,TK,HK,IND,AUS" now if we see 1st occurance of , is at 3 position, 2nd at 6,..4th at 13 position. 1st position we can find through INDEX, but what about 2nd,3rd and 4th or may be upto nth position. ? In oracle we had... (2 Replies)
Discussion started by: Jonty Immortal
2 Replies

10. Shell Programming and Scripting

awk or other way to find out number of occurrence of 7th character

Hi all, I am looking for to filter out based on 7th character and list the number of occurrence based on the 7th character if p , d , o or m 1. if 7th character is p , Output should be: p_hosts = N 2. if 7th character is d , Output should be: d_hosts = N 3. if 7th character is o , Output... (10 Replies)
Discussion started by: rveri
10 Replies
TRNA2SAP(1)						     NCBI Tools User's Manual						       TRNA2SAP(1)

NAME
trna2sap - convert tRNAscan-SE output to an ASN.1 Seq-annot object SYNOPSIS
trna2sap [-] [-a] [-c str] [-f str] [-i filename] [-j] [-m str] [-n str] [-o filename] [-p dir] [-r dir] [-s] [-t str] [-u] [-x str] DESCRIPTION
trna2sap reads a text file produced by tRNAscan-SE and produces a corresponding ASN.1 Seq-annot in the format understood by other NCBI tools. OPTIONS
A summary of options is included below. - Print usage message -a Add tRNAscan-SE citation -c str Comment -f str Substring Filter -i filename Single Input file (standard input by default) -j Just produce a five-column feature table, a la trna2tbl(1). -m str ReMark -n str Annotation Name (normally "tRNA"). -o filename Single Output file (standard output by default) -p dir Path to files -r dir Path for Results -s Ignore Pseudo tRNAs -t str Annotation Title (normally "tRNAscan-SE"). -u Ignore Undetermined tRNAs -x str File selection suffix with -p (.trna by default). AUTHOR
The National Center for Biotechnology Information. SEE ALSO
sequin(1), tbl2asn(1), trna2tbl(1). NCBI
2006-01-11 TRNA2SAP(1)
All times are GMT -4. The time now is 11:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy