How to get the most left hand string ??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get the most left hand string ??
# 1  
Old 09-11-2006
Data How to get the most left hand string ??

Hi,

I remember once seeing a way to get the left most string in a word.
Let's say: a="First.Second.Third" (separated by dot)

echo ${a#*.} shows --> Second.Third
echo ${a##*.} shows --> Third

How do I get the the left most string "First" Or "First.Second" ???

Tried to replace # with + , but it doesn't work.
Can anyone help me?

Thanks,
Joao.
# 2  
Old 09-11-2006
echo ${a%%.*} # First
Remove longest match of .* (dot to end of string ) from back of string

echo ${a%.*} # First.Second
Remove shortest match of .* (dot to end of string ) from back of string

Last edited by anbu23; 09-11-2006 at 04:32 PM..
# 3  
Old 09-11-2006
MySQL

Thanks it worked just fine.

Joao.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Just want to ask if there is a shorter hand to doing this one liner

Hi all, In Oracle, I am using SQL*Plus and selecting all rows in a table and spooling to a file as pipe delimited. I have to use pagesize 0 but unfortunately, using this option excludes the header and I can't get around having it to display the header fields. So to get around this, I have to... (2 Replies)
Discussion started by: newbie_01
2 Replies

2. Shell Programming and Scripting

Matching number of syllables on right-hand and left side

I am developing a database for translating names. I have mapped through a rule engine syllables in English to syllables in Indic, delimited by an equal to sign. An example will illustrate this ra m=रा म ku ma r=कु मा र mo=मो la l=ला ल gi ta=गी ता ka la va ti=कa ला वa ती However it so... (3 Replies)
Discussion started by: gimley
3 Replies

3. Shell Programming and Scripting

Regex to hunt for a string in the right hand column

I have a database which has the following structure English word=IPA notation as in the example below huckleberry=ˈhʌkəl-bəriː huddling=ˈhʌd-lɪŋ huffish=ˈhʌ-fɪʃ hugger-mugger=ˈhʌgər-mʌgər hulling=ˈhʌ-lɪŋ human=ˈhjuː-mən humanitarian=hjuːˌ-mænɪˈteərɪyən... (7 Replies)
Discussion started by: gimley
7 Replies

4. Shell Programming and Scripting

Merge left hand strings mapping to different right hand strings

Hello, I am working on an Urdu to Hindi dictionary which has the following structure: a=b a=c n=d n=q and so on. i.e. Headword separated from gloss by a = I am giving below a live sample بتا=बता بتا=बित्ता بتا=बुत्ता بتان=बतान بتان=बितान بتانا=बिताना I need the following... (3 Replies)
Discussion started by: gimley
3 Replies

5. Shell Programming and Scripting

Place , character after 3 digits from left to right in a string

Hi All, Could anyone please help me, how to put ‘,' character after 3 digits from right to left count,among 17 digits sting. unix scripting Example - I am having 12345678911234567 digits Accepted result-- 12,345,678,911,234,567 Note- 12345678911234567 digits will be dynamic at run time, I... (13 Replies)
Discussion started by: krupasindhu18
13 Replies

6. Shell Programming and Scripting

Terminate left side portion of a string

I have a awk file which consists of the follwoing code in file select.awk : /xxx/ { time = gensub(/xxx \*\*\*(.*)/, "\\1", "g") printf("%s\n",time) next } and an input file with the following file file.txt :- xxx ***Wed May 2 18:00:00 CDT 2012 AAA AAAA AAAA xxx... (4 Replies)
Discussion started by: shikshavarma
4 Replies

7. UNIX Desktop Questions & Answers

Old hand to FreeBSD, brand new to KDE ??'s

I have now used FreeBSD from eh, 5.0??? But during that whole time I have never used xwindows or kde. My box's have always been servers of one type or another. I just set up a new BSD machine(8.0), and because I wanted to install boinc I knew that I would have to also install xwindows. Just the... (4 Replies)
Discussion started by: droolin
4 Replies

8. Debian

change initramfs by hand?

What's the correct way to change the initramfs file that's used during boot? I know that it's a gzipped cpio archive, but when I gunzip, extract, re-archive (without changing any files), and gzip, then the result is that the system does not boot any more. And I even set the cpio archive type. ... (18 Replies)
Discussion started by: frankie06
18 Replies

9. Shell Programming and Scripting

Need a hand. Please?

i have a script in sh. with awk, e.g. want to list all the contents of a subdirectory an a tabular way. ej: outoput directory1 subdirectory1 subdirectory2 subdirectory3 file1 filen file2 filez file2 ... filen+1 ... (1 Reply)
Discussion started by: alexcol
1 Replies

10. UNIX for Dummies Questions & Answers

Give us a hand

How do you get an awk output into columns i.e. awk (print $1,$2,$3) doesn't come out into nice columns but lots of lines of txt want something more like. I am crap at unix so give me a hand thx Rich (3 Replies)
Discussion started by: RichardB
3 Replies
Login or Register to Ask a Question