Sponsored Content
Full Discussion: thousands separator
Top Forums Shell Programming and Scripting thousands separator Post 302184854 by drl on Sunday 13th of April 2008 10:43:24 AM
Old 04-13-2008
Hi.

Who could live without a perl version:
Code:
perl -wpe '1 while s/(.*\d)(\d{3})/$1,$2/'

I like the brevity of the radoulov awk version, and the small size of the sed executable:
Code:
-rwxr-xr-x  1   41048 Nov 30  2004 /bin/sed*
-rwxr-xr-x  1  311308 Nov 26  2004 /usr/bin/awk*
-rwxr-xr-x  2 1057324 Mar  8  2005 /usr/bin/perl*

cheers, drl
This User Gave Thanks to drl For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Multiple (thousands) of Cron Instances

Hey all, I have a box running SUSE SLES 8 and in the past few months the box will randomly spawn thousands of instances of /USR/SBIN/CRON to the point where the box will lock up entirely. Upwards of 14000 instances! I imagine it's using up all of the available files that can be opened at one... (10 Replies)
Discussion started by: sysera
10 Replies

2. Shell Programming and Scripting

Finding a specific pattern from thousands of files ????

Hi All, I want to find a specific pattern from approximately 400000 files on solaris platform. Its very heavy for me to grep that pattern to each file individually. Can anybody suggest me some way to search for specific pattern (alpha numeric) from these forty thousand files. Please note that... (6 Replies)
Discussion started by: aarora_98
6 Replies

3. Solaris

script for Gzip thousands of file

Hi experts, I have thousands of file (data file and Gziped file) in same directory like below-- bash-2.05$ pwd /home/mmc bash-2.05$ file PP023149200709270546 TT023149200709270546: gzip compressed data - deflate method bash-2.05$ file PP027443200711242320 TT027443200711242320: ... (10 Replies)
Discussion started by: thepurple
10 Replies

4. UNIX for Advanced & Expert Users

Copying Thousands of Tiny or Empty Files?

There is a procedure I do here at work where I have to synchronize file systems. The source file system always has three or four directories of hundreds of thousands of tiny (1k or smaller) or empty files. Whenever my rsync command reaches these directories, I'm waiting for hours for those files... (3 Replies)
Discussion started by: deckard
3 Replies

5. UNIX for Dummies Questions & Answers

How to truncate thousands of file names

Folder of e-mails in maildir format had been corrupted. Typical file name is 1246281161.6777.m21JH:2,S . The " :2,S prevents " copying to another device. How can I simply remove the last four characters? (2 Replies)
Discussion started by: steve900
2 Replies

6. Shell Programming and Scripting

help to parallelize work on thousands of files

I need to find a smarter way to process about 60,000 files in a single directory. Every night a script runs on each file generating a output on another directory; this used to take 5 hours, but as the data grows it is taking 7 hours. The files are of different sizes, but there are 16 cores... (10 Replies)
Discussion started by: vhope07
10 Replies

7. Shell Programming and Scripting

Search for patterns in thousands of files

Hi All, I want to search for a certain string in thousands of files and these files are distributed over different directories created daily. For that I created a small script in bash but while running it I am getting the below error: /ms.sh: xrealloc: subst.c:5173: cannot allocate... (17 Replies)
Discussion started by: danish0909
17 Replies

8. Shell Programming and Scripting

Bash-awk to process thousands of files

Hi to all, I have thousand of files in a folder with names with format "FILE-YYYY-MM-DD-HHMM" for what I want to send the following AWK command awk '/Code.*/' FILE-2014* I'd like to separate all files that have the same date to a folder named with the corresponding date. For example, if I... (7 Replies)
Discussion started by: Ophiuchus
7 Replies
String::Dirify(3pm)					User Contributed Perl Documentation				       String::Dirify(3pm)

NAME
"String::Dirify" - Convert a string into a directory name Synopsis use String::Dirify; my($dir_1) = String::Dirify -> dirify('frobnitz'); Or: use String::Dirify ':all'; my($dir_2) = dirify('bar baz'); Or even: use String::Dirify; my($sd) = String::Dirify -> new(); my($dir_3) = $sd -> dirify('!Q@W#E$R%T^Y'); Description "String::Dirify" is a pure Perl module. This module allows you to convert a string (possibly containing high ASCII characters, and even HTML) into another, lower-cased, string which can be used as a directory name. For usage, see the Synopsis. This code is derived from similar code in Movable Type. Method: dirify($string [, $separator]) Returns a string, which can be used as a directory name. The default separator is '_'. Each run of spaces in the string is replaced by this separator. Algorithm 1: Each high ASCII character is replaced by its normal equivalent 2: The string is converted to lower case 3: Any HTML (including HTML entities) in the string is removed 4: Any characters which are not (Perl) words, spaces or hyphens, are removed 5: Runs of spaces are converted to the separator character For more details about this character, see the discussion of the dirify() method (above). Melody 'v' Movable Type See http://openmelody.org for details. Backwards Compatibility with Movable Type Unfortunately, Movable Type's usage of dirify() allows a fake separator - '1' - to be used for the second parameter in the call to dirify(). The '1' triggered usage of '_' as the separator, rather than the '1' provided. This 'feature' has been preserved in "String::Dirify", but is discouraged. Instead, simply drop the second parameter and let the code default to '_'. Distributions This module is available as a Unix-style distro (*.tgz). See http://savage.net.au/Perl-modules.html for details. Authors "String::Dirify" started out as part of Movable Type's code. Then, Mark Stosberg cut down the original code to provide just the English/ISO/ASCII features. Lastly, the code was cleaned up, tests added, and all packaged, by Ron Savage <ron@savage.net.au> in 2009. Home page: http://savage.net.au/index.html Copyright (c) 2009, Mark Stosberg, Ron Savage. Copyright (c) 2010, 2011, Ron Savage. perl v5.10.1 2011-01-08 String::Dirify(3pm)
All times are GMT -4. The time now is 11:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy