Sponsored Content
Top Forums Shell Programming and Scripting replace space with delimiter in whole file -perl Post 302167526 by meghana on Thursday 14th of February 2008 05:02:21 PM
Old 02-14-2008
replace space with delimiter in whole file -perl

Hi

I have a file which have say about 100,000 records..
the records in it look like

Some kind of text 1234567891 abcd February 14, 2008 03:58:54 AM lmnop

This is how it looks.. if u notice there is a 2byte space between each column.. and im planning to replace that with '|' ..

say ..

Some kind of text|1234567891|abcd|February 14, 2008 03:58:54 AM|lmnop

.. here is the code which i have written.. but someone should help me in completing it... thanks in advance

open(fh_tmp,"<","$chk_file");
while (my $line = <fh_tmp>)
{
$line =~ s/ /|/g ;
open(out,">>",tmpfile);
print out $line;
close(out);
}
close(fh_tmp);


please correct me if im wrong.. thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace delimiter : with '\001' in unix data file

HI can any one tell me how to replace a delimiter : with another delimiter '\001' it is a non printable octal character. thanks in adv spandu (4 Replies)
Discussion started by: spandu
4 Replies

2. Shell Programming and Scripting

how to differentiate columns of a file in perl with no specific delimiter

Hi everybody, This time I am having one issue in perl. I have to create comma separated file using the following type of information. The problem is the columns do not have any specific delimiter. So while using split I am getting different value. Some where it is space(S) and some where it is... (9 Replies)
Discussion started by: Amiya Rath
9 Replies

3. Shell Programming and Scripting

replace space with comma in perl

arr_Ent_NameId variable holds 'Prakash pawar' 'sag' '23' '50000' this value 'Prakash pawar' 'sag' '23' '50000' I want to replace space( ) with comma (,) There are 4 fields here. I don't want to replace first field with comma. output should be: 'Prakash,pawar','sag','23','50000' ... (2 Replies)
Discussion started by: pritish.sas
2 Replies

4. Shell Programming and Scripting

comma delimiter and space

I have a csv file and there is a problem which I need to resolve. Column1,Column2,Colum3,Column4 ,x,y,z ,d,c,v t,l,m,n ,h,s,k ,k,,y z,j, ,p Now if you see column1 for row 1 and row 4 though they are null there is a space but in case of row2 and row 5 there is no space. I want row... (3 Replies)
Discussion started by: RubinPat
3 Replies

5. Shell Programming and Scripting

Space as a delimiter

not sure if i'm doing this right i'm new tho this but i'm trying to use a space as a delimiter with the cut command my code is size=$( du -k -S -s /home/cmik | cut -d' ' -f1 ) i've also tried -f2 and switching the -d and -f around if that does anything (3 Replies)
Discussion started by: Cmik
3 Replies

6. Shell Programming and Scripting

Need to use delimiter as : and space in awk

Hi , Please suggest me how do I use : (colon and one space) as a delimiter in awk Best regards, Vishal (2 Replies)
Discussion started by: Vishal_dba
2 Replies

7. Shell Programming and Scripting

Perl Code to change file delimiter (passed as argument) to bar delimiter

Hi, Extremely new to Perl scripting, but need a quick fix without using TEXT::CSV I need to read in a file, pass any delimiter as an argument, and convert it to bar delimited on the output. In addition, enclose fields within double quotes in case of any embedded delimiters. Any help would... (2 Replies)
Discussion started by: JPB1977
2 Replies

8. Shell Programming and Scripting

Replace file name with Space as content

Hi, I am having a files in my directory like this: 2014 1049_file1.txt 2014 1050_file2.txt 2014 1110_file3.txt 2014 1145_file4.txt 2014 2049_file5.txt I need to replace the above file names like this without changing the content of filename: file1.txt file2.txt file3.txt... (10 Replies)
Discussion started by: rohit_shinez
10 Replies

9. Shell Programming and Scripting

Replace a space with underscore in a file

i have a file with following data. { EqName "Tan 1" .... .... } { EqName "Sin 2" ... ... } I have to replace the value of EqName to Tan_1 and Sin_2 in file.Can i use sed or awk ? cat file|grep EqName|awk '{print $2 $3}'|sed -i 's//_/g' I tried with this but it... (2 Replies)
Discussion started by: Jag02
2 Replies

10. Shell Programming and Scripting

Replace delimiter for a particular column in a pipe delimited file

I have an input file as below Emp1|FirstName|MiddleName|LastName|Address|Pincode|PhoneNumber 1234|FirstName1|MiddleName2|LastName3| Add1 || ADD2|123|000000000 Output : 1234|FirstName1|MiddleName2|LastName3| Add1 ,, ADD2|123|000000000 OR 1234,FirstName1,MiddleName2,LastName3, Add1 ||... (2 Replies)
Discussion started by: styris
2 Replies
DateTime::Locale::sid(3)				User Contributed Perl Documentation				  DateTime::Locale::sid(3)

NAME
DateTime::Locale::sid SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'sid' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Sidamo. DATA
This locale inherits from the DateTime::Locale::root locale. It contains the following data. Days Wide (format) Sanyo Maakisanyo Roowe Hamuse Arbe Qidaame Sambata Abbreviated (format) San Mak Row Ham Arb Qid Sam Narrow (format) S M R H A Q S Wide (stand-alone) Sanyo Maakisanyo Roowe Hamuse Arbe Qidaame Sambata Abbreviated (stand-alone) San Mak Row Ham Arb Qid Sam Narrow (stand-alone) S M R H A Q S Months Wide (format) January February March April May June July August September October November December Abbreviated (format) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Narrow (format) J F M A M J J A S O N D Wide (stand-alone) January February March April May June July August September October November December Abbreviated (stand-alone) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Narrow (stand-alone) J F M A M J J A S O N D Quarters Wide (format) Q1 Q2 Q3 Q4 Abbreviated (format) Q1 Q2 Q3 Q4 Narrow (format) 1 2 3 4 Wide (stand-alone) Q1 Q2 Q3 Q4 Abbreviated (stand-alone) Q1 Q2 Q3 Q4 Narrow (stand-alone) 1 2 3 4 Eras Wide BCE CE Abbreviated YIA YIG Narrow YIA YIG Date Formats Full 2008-02-05T18:30:30 = Maakisanyo, February 05, 2008 1995-12-22T09:05:02 = Arbe, December 22, 1995 -0010-09-15T04:44:23 = Qidaame, September 15, -10 Long 2008-02-05T18:30:30 = 05 February 2008 1995-12-22T09:05:02 = 22 December 1995 -0010-09-15T04:44:23 = 15 September -10 Medium 2008-02-05T18:30:30 = 05-Feb-2008 1995-12-22T09:05:02 = 22-Dec-1995 -0010-09-15T04:44:23 = 15-Sep--10 Short 2008-02-05T18:30:30 = 05/02/08 1995-12-22T09:05:02 = 22/12/95 -0010-09-15T04:44:23 = 15/09/-10 Default 2008-02-05T18:30:30 = 05-Feb-2008 1995-12-22T09:05:02 = 22-Dec-1995 -0010-09-15T04:44:23 = 15-Sep--10 Time Formats Full 2008-02-05T18:30:30 = 6:30:30 hawwaro UTC 1995-12-22T09:05:02 = 9:05:02 soodo UTC -0010-09-15T04:44:23 = 4:44:23 soodo UTC Long 2008-02-05T18:30:30 = 6:30:30 hawwaro UTC 1995-12-22T09:05:02 = 9:05:02 soodo UTC -0010-09-15T04:44:23 = 4:44:23 soodo UTC Medium 2008-02-05T18:30:30 = 6:30:30 hawwaro 1995-12-22T09:05:02 = 9:05:02 soodo -0010-09-15T04:44:23 = 4:44:23 soodo Short 2008-02-05T18:30:30 = 6:30 hawwaro 1995-12-22T09:05:02 = 9:05 soodo -0010-09-15T04:44:23 = 4:44 soodo Default 2008-02-05T18:30:30 = 6:30:30 hawwaro 1995-12-22T09:05:02 = 9:05:02 soodo -0010-09-15T04:44:23 = 4:44:23 soodo Datetime Formats Full 2008-02-05T18:30:30 = Maakisanyo, February 05, 2008 6:30:30 hawwaro UTC 1995-12-22T09:05:02 = Arbe, December 22, 1995 9:05:02 soodo UTC -0010-09-15T04:44:23 = Qidaame, September 15, -10 4:44:23 soodo UTC Long 2008-02-05T18:30:30 = 05 February 2008 6:30:30 hawwaro UTC 1995-12-22T09:05:02 = 22 December 1995 9:05:02 soodo UTC -0010-09-15T04:44:23 = 15 September -10 4:44:23 soodo UTC Medium 2008-02-05T18:30:30 = 05-Feb-2008 6:30:30 hawwaro 1995-12-22T09:05:02 = 22-Dec-1995 9:05:02 soodo -0010-09-15T04:44:23 = 15-Sep--10 4:44:23 soodo Short 2008-02-05T18:30:30 = 05/02/08 6:30 hawwaro 1995-12-22T09:05:02 = 22/12/95 9:05 soodo -0010-09-15T04:44:23 = 15/09/-10 4:44 soodo Default 2008-02-05T18:30:30 = 05-Feb-2008 6:30:30 hawwaro 1995-12-22T09:05:02 = 22-Dec-1995 9:05:02 soodo -0010-09-15T04:44:23 = 15-Sep--10 4:44:23 soodo Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 Mak 1995-12-22T09:05:02 = 22 Arb -0010-09-15T04:44:23 = 15 Qid Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 hawwaro 1995-12-22T09:05:02 = 9:05 soodo -0010-09-15T04:44:23 = 4:44 soodo Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 hawwaro 1995-12-22T09:05:02 = 9:05:02 soodo -0010-09-15T04:44:23 = 4:44:23 soodo M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (M-d) 2008-02-05T18:30:30 = 2-5 1995-12-22T09:05:02 = 12-22 -0010-09-15T04:44:23 = 9-15 MEd (E, M-d) 2008-02-05T18:30:30 = Mak, 2-5 1995-12-22T09:05:02 = Arb, 12-22 -0010-09-15T04:44:23 = Qid, 9-15 MMdd (dd/MM) 2008-02-05T18:30:30 = 05/02 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/09 MMM (LLL) 2008-02-05T18:30:30 = Feb 1995-12-22T09:05:02 = Dec -0010-09-15T04:44:23 = Sep MMMd (MMM d) 2008-02-05T18:30:30 = Feb 5 1995-12-22T09:05:02 = Dec 22 -0010-09-15T04:44:23 = Sep 15 MMMEd (E MMM d) 2008-02-05T18:30:30 = Mak Feb 5 1995-12-22T09:05:02 = Arb Dec 22 -0010-09-15T04:44:23 = Qid Sep 15 MMMMd (MMMM d) 2008-02-05T18:30:30 = February 5 1995-12-22T09:05:02 = December 22 -0010-09-15T04:44:23 = September 15 MMMMdd (dd MMMM) 2008-02-05T18:30:30 = 05 February 1995-12-22T09:05:02 = 22 December -0010-09-15T04:44:23 = 15 September MMMMEd (E MMMM d) 2008-02-05T18:30:30 = Mak February 5 1995-12-22T09:05:02 = Arb December 22 -0010-09-15T04:44:23 = Qid September 15 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (y-M) 2008-02-05T18:30:30 = 2008-2 1995-12-22T09:05:02 = 1995-12 -0010-09-15T04:44:23 = -10-9 yMEd (EEE, y-M-d) 2008-02-05T18:30:30 = Mak, 2008-2-5 1995-12-22T09:05:02 = Arb, 1995-12-22 -0010-09-15T04:44:23 = Qid, -10-9-15 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 Feb 1995-12-22T09:05:02 = 1995 Dec -0010-09-15T04:44:23 = -10 Sep yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = Mak, 2008 Feb 5 1995-12-22T09:05:02 = Arb, 1995 Dec 22 -0010-09-15T04:44:23 = Qid, -10 Sep 15 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 February 1995-12-22T09:05:02 = 1995 December -0010-09-15T04:44:23 = -10 September yQ (y Q) 2008-02-05T18:30:30 = 2008 1 1995-12-22T09:05:02 = 1995 4 -0010-09-15T04:44:23 = -10 3 yQQQ (y QQQ) 2008-02-05T18:30:30 = 2008 Q1 1995-12-22T09:05:02 = 1995 Q4 -0010-09-15T04:44:23 = -10 Q3 yyMM (MM/yy) 2008-02-05T18:30:30 = 02/08 1995-12-22T09:05:02 = 12/95 -0010-09-15T04:44:23 = 09/-10 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 yyyyMMMM (MMMM y) 2008-02-05T18:30:30 = February 2008 1995-12-22T09:05:02 = December 1995 -0010-09-15T04:44:23 = September -10 Miscellaneous Prefers 24 hour time? No Local first day of the week Sanyo SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.16.2 2013-08-25 DateTime::Locale::sid(3)
All times are GMT -4. The time now is 01:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy