Sponsored Content
Top Forums Shell Programming and Scripting perl - Removing dots(".") from the data Post 302743133 by i150371485 on Wednesday 12th of December 2012 07:01:12 AM
Old 12-12-2012
Question perl - Removing dots(".") from the data

Hi Friends,


I have a file1 as below

file1.txt

Code:
 
100000.||1925-01-10|00:00|1862SHERMA NAVE#1SE.||EVTON|IL|60201||22509.|BDSS|62007|2639.|26670
100001.||1935-01-10|00:00|1862NEW . YRK NO.||EVTON|IL|60201||22509.|BDSS|62007|2639.|26670.
100002.||1965-01-10|00:00|1862 IND . INC,CL .NAVE#1SE.||EVTON|IL|60201||22.509.|BDSS|62007.|2.639.|26670

I am using the below command to remove the dots"." from the file where before "|'


Code:
 
#perl -pe 's/\.(?=[|\s])//g' file1.txt
 
100000||1925-01-10|00:00|1862SHERMA NAVE#1SE||EVTON|IL|60201||22509|BDSS|62007|2639|26670
100001||1935-01-10|00:00|1862NEW  YRK NO||EVTON|IL|60201||22509|BDSS|62007|2639|26670
100002||1965-01-10|00:00|1862 IND  INC,CL .NAVE#1SE||EVTON|IL|60201||22.509|BDSS|62007|2.639.|26670


The output will remove all the dots for the interger fields and also the Address field which is mentioned as green .But i want to remove the dots only when column field is Integer and want to remove dot"." only before "|"

Expected output:

Code:
 
100000||1925-01-10|00:00|1862SHERMA NAVE#1SE.||EVTON|IL|60201||22509|BDSS|62007|2639|26670
100001||1935-01-10|00:00|1862NEW . YRK NO.||EVTON|IL|60201||22509|BDSS|62007|2639|26670
100002||1965-01-10|00:00|1862 IND . INC,CL .NAVE#1SE.||EVTON|IL|60201||22.509|BDSS|62007|2.639.|26670

Plz help

Last edited by i150371485; 12-12-2012 at 08:31 AM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

removing the "\" and "\n" character using sed or tr

Hi All, I'm trying to write a ksh script to parse a file. When the "\" character is encountered, it should be removed and the next line should be concatenated with the current line. For example... this is a test line #1\ should be concatenated with line #2\ and line number 3 when this... (3 Replies)
Discussion started by: newbie_coder
3 Replies

3. Shell Programming and Scripting

show dots when script is "thinking"

Hey, I'm running the following script: #!/bin/bash kjv=kjv.txt trim(){ local trim_string local _TRIM=$1 trim_string=${_TRIM##*} _TRIM=${_TRIM#"trim_string"} echo $_TRIM } #trim() { # echo $( _trim "$@" ) #} printf "How many chapters? " read response (10 Replies)
Discussion started by: pkohn11
10 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Removing "^M" from the end of a String (i.e. "Ctrl+M")?

Hello All, I have an Expect script that ssh's to a remote server and runs some commands before exiting. One of the commands I run is the "hostname" Command. After I run this command I save the output using this line in the code below... Basically it executes the hostname command, then I... (2 Replies)
Discussion started by: mrm5102
2 Replies

6. Shell Programming and Scripting

Awk-sed - wc : how to count DOTS "."'s in a file.

Hi Experts , file: EST 2013::.................................................................................................................................................................................................................................................cmihx021:/home/data1/ ... (11 Replies)
Discussion started by: rveri
11 Replies

7. Shell Programming and Scripting

Perl scripting to get "Wanted Data"

I have data like below : Source file : input.txt ( so many data with same format ) 09.05.2014 09.49.52:359 RID:routerNode1@app1:1662306081,msisdn:787887225696,sid:93889095007001,tid:1405090902095648846024000,status:2,time:20140509094952,reason:DELIVRD,refund:null,status2:null ... (6 Replies)
Discussion started by: MacLing66
6 Replies

8. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
set_color(1)                                                           fish                                                           set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 02:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy