Remove prefixes before dot


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove prefixes before dot
# 1  
Old 08-23-2017
Remove prefixes before dot

Shell : Bash shell

I have a text file with entries like below

Code:
srv.sr_num sr_number, atvx.ATTRIB_37 Product_Name, ktx.X_ATTRIB_52 Product_Type, mkx.created sr_created_date, nbv.sr_cat_type_cd sr_type, bkrx.sr_area sr_category, .. 
frx.order_id, des.stats_name , fpxg.current_id_name, ......
.
.

I want to remove all the prefixes before the dot. Any idea how I could achieve this ?

Expcted output:
Code:
sr_num sr_number, ATTRIB_37 Product_Name, X_ATTRIB_52 Product_Type, created sr_created_date, sr_cat_type_cd sr_type, sr_area sr_category, .. 
order_id, stats_name , current_id_name, ......
.
.

# 2  
Old 08-23-2017
Code:
awk '{for (i=1; i<=NF; i++) sub("^[^.]+[.]", "", $i); print $0}' infile


Last edited by rdrtx1; 08-23-2017 at 11:48 AM..
This User Gave Thanks to rdrtx1 For This Post:
# 3  
Old 08-23-2017
Thank You rdrtx1.
I forgot to mention, that I need to remove the dots as well (as shown in the Expected output).
But, I can live with your solution (ie. I can easily remove the dots using vi ). Thanks again
# 4  
Old 08-23-2017
Try also
Code:
sed 's/[^., ]\+\.//g'

This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mv or cp with a . (dot)?

How can I rename a file with a . prefix? I actually need to copy the file but the . seems to be very tough to do. mv ./bla ../fa/la/.bla - doesn't work. I've tried all sorts of bracketing and that doesn't work. Maybe the only way to do it would be to name the file _.bla then rename it... (19 Replies)
Discussion started by: scribling
19 Replies

2. Shell Programming and Scripting

Remove leading dot and slash on relative paths with find

When I specify a directory by name the leading ./ is not shown: $ find somedir/ somedir/a.bin somedir/target/out.binBut when I specify current dir it adds the ./ to the beginning of each result: $ find . | grep somedir ./somedir/a.bin ./somedir/target/out.binIs there any particular reason why... (2 Replies)
Discussion started by: Tribe
2 Replies

3. Shell Programming and Scripting

How to remove. (dot) if found in the beginning of file name while doing wget (download)?

Dear All, How to remove. (dot) if found in the beginning of file name while doing wget (download)? I am facing problem while re-sizing the image by using ImageMagick. Two dots in the file name are causing problem. ImageMagick is skipping such image with a dot . in the beginning, like ... (1 Reply)
Discussion started by: Praveen Pandit
1 Replies

4. Shell Programming and Scripting

how to remove a variable starting with dot using sed command

Hi, I want to remove a variable starting with dot(.) in a file using sed command. aaa sss .abc s/^\.abc/d I tried this but it didnt worked. (5 Replies)
Discussion started by: vdhingra123
5 Replies

5. Shell Programming and Scripting

Start from the prefixes, delete script

My folder is/app2/istech/scratch, which contain all the below files. I need to delete the files which start from the prefixes. dup_events_*.* Event_*.* New_time_*.* New_Loc_*.* New_Uptime_*.* Detailed_Reason*.* cmt_dup_*.* Uptime_*.* Can anyone please let me know how to write a... (3 Replies)
Discussion started by: dsnaveen
3 Replies

6. Shell Programming and Scripting

counting prefixes of files

Hello, at the moment I'm on with programming some kind of version history script for network devices. The configration files are uploaded in the form: devicename-confg_date_time. For keeping the last 10 configurations I want to split the devicename from the rest. This works well with... (5 Replies)
Discussion started by: Sally[-_-]
5 Replies

7. UNIX for Dummies Questions & Answers

vi editor prefixes lines with # upon paste

I've been away from Unix and the vi editor for a while, and now I'm using vi (actually vim) in a Cygwin bash shell. When I copy-and-paste code examples (I'm playing with perl now) any time I paste code with lines beginning with the # character, vi inserts a # character at the beginning of every... (2 Replies)
Discussion started by: greenmangroup
2 Replies

8. UNIX for Dummies Questions & Answers

variable name with dot(.)

Hi, Is it possible to declare variable with name having dot(.) in it ? something like gs.test='HELLO' Thanks in advance :) (1 Reply)
Discussion started by: gopalss
1 Replies

9. Shell Programming and Scripting

dot files

Hi, everyone. I'm now using rsync command, and please tell me what is the wildcard for below looks like. I want to chose dotfiles, such as .ipod .apple but i don't want to chose . and .. ------------------ .* doesn't work, of course. Thanks, Euler04 (2 Replies)
Discussion started by: Euler04
2 Replies
Login or Register to Ask a Question