Visit Our UNIX and Linux User Community


searching for words between delimeters from the rear


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting searching for words between delimeters from the rear
# 1  
Old 08-04-2009
Power searching for words between delimeters from the rear

Hi,
i need to pick up dates and times from the file names which are of unequal length. The dates and time are delimited by dot. I am interested in getting the strings between the delimeter for fields -3, -4, -5 from behind (rear) so that the out put looks like :

071118.011300.556

I have tried with awk -F'.' '{print $3 '.'$4 '.'$5'}' filename
There is no consistency in the extractiion and i dont know how to read from the back which would have been more consistent.

See examples of filenames below:

nwg_0x005f_200611501-071118.011300.556.d3v4r5.bk

499c-9b4c-7808972f621d.7808972f621d.7808972f621d.7808972f621d.081222.201727.977.d3v70r764.bk

_cheshir.8c671a28-9a9d-42e9-96fd-02304c85bbf3.02304c85bbf3.02304c85bbf3.02304c85bbf3.090219.183923.709.d3v89r1353.bk

HC-071128.002729.081.d3v46r195.bk

al_0x005f_Publish-070724.195338.244.d3v9r20.bk

I need help.

Regards

Last edited by oktbabs; 08-04-2009 at 12:46 PM..
# 2  
Old 08-04-2009
Give in and out example. Easier to give solution.
# 3  
Old 08-04-2009
Code:
sed 's/.*\([0-9]\{6\}.[0-9]\{6\}.[0-9]\{3\}\).*/\1/' file

Please use [code] tags when you post code or data sample.

Previous Thread | Next Thread
Test Your Knowledge in Computers #724
Difficulty: Medium
The Plan 9 operating system was the first machine to achieve a Master rating in chess.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Lines between specific delimeters

Hi, I have a requirement like this Line 1 Line 2 Line 3 Manager Line 4 Line 5 I have to print like this Have you done your work on time because I have to forward the work forward. Any Help is really Appriciated.... (1 Reply)
Discussion started by: abhishek7687
1 Replies

2. UNIX for Dummies Questions & Answers

searching words & print prefixed string after it

I have a text which I divided them into sentences and now printed them in a rows. I want to get the list of most of words ( the, and, a) and print 5 words after them (so 6 with the word itself). I have created an acceptfile with those rows and using grep but I have rows that have these words more... (2 Replies)
Discussion started by: A-V
2 Replies

3. Shell Programming and Scripting

Finding my lost file by searching for words in it

Got a question for you guys...I am searching through a public directory (that has tons of files) trying to find a file that I was working on a longggggg time ago. I can't remember what it is called, but I do remember the content. It should contains words like this: Joe Pulvo botnet zeus... (5 Replies)
Discussion started by: statichazard
5 Replies

4. Shell Programming and Scripting

Awk: Searching for length of words between slash character

Dear UNIX Community, I have a set of file paths like the one below: \\folder name \ folder1 \ folder2 \ folder3 \ folder4 \\folder name \ very long folder name \ even longer name I would like to find the length of the characters (including space) between the \'s. However, I want... (6 Replies)
Discussion started by: vnayak
6 Replies

5. Shell Programming and Scripting

Commas within Delimeters

Hi experts, I would like a favour from you guys to get the info from 5th column which was separated by the delimeter comma ( , ) The Data file is as below:- 1,USER1,"90, TEST AVENUE, OLD ROAD",test1,124,N 2,USER2,88 TEST STREET NEW ROAD,test2,123,N The User File is as below:- USER1... (1 Reply)
Discussion started by: shenkz
1 Replies

6. UNIX for Dummies Questions & Answers

Searching for multiple words on a line in any order issue

Hi again I have figured out how to be able to sort through lines in a file with multiple words in any order and display them using this command: cat file | grep -i $OPTION1 | grep -i $OPTION2 | grep -i $OPTION3 OPTION1 is 2008, OPTION2 is Mar, OPTION 3 is Tue Result: Tue Mar 25... (4 Replies)
Discussion started by: semaj
4 Replies

7. Shell Programming and Scripting

Perl searching special words in lines

Hi , i am a new with perl, i want to made a script that find in file rows that start with specil words, as an example a line will start with" ............................................. specialword aaa=2 bbb=5 ............................................. and to put this in a new file... (3 Replies)
Discussion started by: alinalin
3 Replies

8. Shell Programming and Scripting

Searching words in a file containing a pattern

Hi all, I would like to print words in a file seperated by whitespaces containing a specific pattern like "=" e.g. I have a file1 containing strings like %cat file1 The= some= in wish= born <eof> .I want to display only those words containing = i.e The= , some=,wish= ... (5 Replies)
Discussion started by: sree_123
5 Replies

9. Shell Programming and Scripting

awk with two delimeters

Hi, can anyone explain me below codes...i used the below one to use two delimeter(://) at a time.. but i am not able to understand the output options.. note: here there is no requirement ..only to understand myself about below command... command: awk -F "" '{print $1}' inputfile ... (2 Replies)
Discussion started by: Shahul
2 Replies

10. UNIX for Dummies Questions & Answers

searching and displaying most commonly used words

Hi guys, i need to search the most commonly occuring words in a file and display their counts of about 30000 words and the words shud not be of typ specified in file 2 e. words like is,for,the,an,he,she etc... k. file1: ALICE was beginning to get very tired of sitting by... (2 Replies)
Discussion started by: arunsubbhian
2 Replies

Featured Tech Videos