take all characters from end to start till a fullstop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting take all characters from end to start till a fullstop
# 1  
Old 09-02-2010
Tools take all characters from end to start till a fullstop

e.g. "hello.all" to be transformed to "all" Smilie
# 2  
Old 09-02-2010
It depends how many dots your string has, and whether you want to keep only the last portion, or delete only the first portion.

i.e.
Code:
echo hello.all | sed "s/.*\.//"
all

echo hello.all.reallyall | sed "s/.*\.//"
reallyall

echo hello.all.reallyall | sed "s/[^\.]*.//"
all.reallyall

If you are reading from a variable, as opposed to a file, then you can do it in the shell:

Code:
$ X=hello.all.reallyall

$ echo ${X##*.}
reallyall

$ echo ${X#*.} 
all.reallyall

This User Gave Thanks to Scott For This Post:
# 3  
Old 09-02-2010
hmmmm...This is a problem to me, but as ll my file extensions (ogg mp3 wav) contain only 3 characters ech, i think I'll use this UNIX.COM - EXTRACTING LAST 3 CHARS
# 4  
Old 09-02-2010
Quote:
Originally Posted by hakermania
hmmmm...This is a problem to me, but as ll my file extensions (ogg mp3 wav) contain only 3 characters ech, i think I'll use this UNIX.COM - EXTRACTING LAST 3 CHARS
Great!

Until you get a .mpeg file Smilie
This User Gave Thanks to Scott For This Post:
# 5  
Old 09-02-2010
or Smilie
Code:
# echo "hello.all" | grep -ow "..."
all

This User Gave Thanks to ygemici For This Post:
# 6  
Old 09-02-2010
My program allow only the selection of mp3 ogg and wav
# 7  
Old 09-03-2010
Code:
echo "hello.all"|cut -d \. -f2
echo "hello.all"|awk -F\. '{print $NF}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

2. Shell Programming and Scripting

Pattern match till the end of the file.

I have a file which is like this ……………………………………….. ………………………………… ………………………………… …………………………………… ……………………………………. ……………………………… <<<from_here>>> ……………………………… ………………………………. I want a script which would fetch the data starting from <<<from_here>>> in the file till the end... (2 Replies)
Discussion started by: halfafringe
2 Replies

3. Shell Programming and Scripting

Print characters till the next space when the pattern is found

i have a file which contains alphanumeric data in every line. what i need is the data after certain pattern. the data after the pattern is not of fixed length so i need the data till the space after the pattern. Input file: bfdkasfbdfg khffkf lkdhfhdf pattern (datarequired data not required)... (2 Replies)
Discussion started by: gpk_newbie
2 Replies

4. Shell Programming and Scripting

Cut line from file till the end

Hi I have a 57 line text file and I want to cut first 6 line assigned it to a veriable and again cut next 6 line assigned to same variable till the time file have left 0 line. Please let me know how I can do in scripting. Thanks Sanjay (6 Replies)
Discussion started by: Sanjay2121
6 Replies

5. Shell Programming and Scripting

Remove line starting from space till end.

Hi, I have a code tag, from which i have the below snippet: intelrpt.GetCMB_FB type=ODBC> intelrpt.GetCMB_FB type=SYBASE> I want the output like: intelrpt.GetCMB_FB intelrpt.GetCMB_FB That is remove the lines starting from WHITESPACE till end. Please help. I am new to... (7 Replies)
Discussion started by: anupdas
7 Replies

6. Shell Programming and Scripting

Grep from a starting line till the end of the file

Hi Folks, I got to know from this forums on how to grep from a particular line say line 6 awk 'NR==6 {print;exit}' But how do i grep from line 6 till the end of the file or command output. Thanks, (3 Replies)
Discussion started by: Mr. Zer0
3 Replies

7. AIX

NFS won't work till I start HACMP

Hi, My NFS does not work till I start HACMP. The NFS service is indeed started when server starts. But it is not in active state, when I use lssrc to check NFS services' status I find they are all in inoperative status. But after I start HACMP (smitty clstart), all NFS services become active... (4 Replies)
Discussion started by: qiulang
4 Replies

8. Shell Programming and Scripting

Need to remove few characters from each line till a pattern is matched

Hi All, I want to remove first few characthers from starting of the line till ',' Comma... which needs to be done for all the lines in the file Eg: File content 1,"1234",emp1,1234 2,"2345",emp2,2345 Expected output is ,"1234",emp1,1234 ,"2345",emp2,2345 How can parse... (4 Replies)
Discussion started by: kiranlalka
4 Replies

9. Shell Programming and Scripting

Subsitute from a position till end of line.

Hi, Having a following file's content, lets say: ABC|ANA|LDJ|||||DKD|||||| AJJ|KKDD||KKDK|||||||||||| KKD||KD|||LLLD||||LLD||||| Problem: Need to replace pipes from 8th occurrence of pipe till end. so the result should be: ABC|ANA|LDJ|||||DKD AJJ|KKDD||KKDK|||| ------- ------- ... (12 Replies)
Discussion started by: _Noprofi
12 Replies

10. Shell Programming and Scripting

Find term and extract till end of data

Hi All, I have an awk code below. How can i edit it such that once it finds the term "start" , it will extract all the rest of data thereafter ? awk '/start/, /stop/' file (4 Replies)
Discussion started by: Raynon
4 Replies
Login or Register to Ask a Question