separate numbers in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting separate numbers in a file
# 8  
Old 03-16-2010
Is this BASH? If so, there's no need for anything other than putting a little builtin parameter expansion on the variable.
Code:
${VAR:3:3}

This extracts a substring from the variable, in this case the text starting after the first three characters and ending after three more characters.
Code:
# VAR1=EMT346.DAT
# echo ${VAR1:3:3}
346
# VAR2=$((${VAR1:3:3}+1))
# echo $VAR2
347
#

or...

# VAR2=EMT$((${VAR1:3:3}+1)).DAT
# echo $VAR2
EMT347.DAT

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding (as in arithmetic) to numbers in columns in file, and writing new file with new numbers

Hi again. Sorry for all the questions — I've tried to do all this myself but I'm just not good enough yet, and the help I've received so far from bartus11 has been absolutely invaluable. Hopefully this will be the last bit of file manipulation I need to do. I have a file which is formatted as... (4 Replies)
Discussion started by: crunchgargoyle
4 Replies

2. Shell Programming and Scripting

Help awk/sed: putting a space after numbers:to separate number and characters.

Hi Experts, How to sepearate the list digit with letters : with a space from where the letters begins, or other words from where the digits ended. file 52087mo(enbatl) 52049mo(enbatl) 52085mo(enbatl) 25051mo(enbatl) The output should be looks like: 52087 mo(enbatl) 52049... (10 Replies)
Discussion started by: rveri
10 Replies

3. Shell Programming and Scripting

Separate two numbers

I would like to separate number by space so that 121231212 222111212 would be 1 2 1 2 3 1 2 1 2 2 2 2 1 1 1 2 1 2 Thanks! (2 Replies)
Discussion started by: johnkim0806
2 Replies

4. Shell Programming and Scripting

How to split a data file into separate files with the file names depending upon a column's value?

Hi, I have a data file xyz.dat similar to the one given below, 2345|98|809||x|969|0 2345|98|809||y|0|537 2345|97|809||x|544|0 2345|97|809||y|0|651 9685|98|809||x|321|0 9685|98|809||y|0|357 9685|98|709||x|687|0 9685|98|709||y|0|234 2315|98|809||x|564|0 2315|98|809||y|0|537... (2 Replies)
Discussion started by: nithins007
2 Replies

5. Shell Programming and Scripting

the smallest number from 90% of highest numbers from all numbers in file

Hello All, I am having problem to find what is the smallest number from 90% of highest numbers from all numbers in file. I am having file with thousands of lines and hundreds of columns. I am familiar mainly with bash but I am open to whatever suggestion witch will lead to the solutions. If I... (11 Replies)
Discussion started by: Apfik
11 Replies

6. Shell Programming and Scripting

separate two numbers separated by :

Hi all i have a data of this form 10.12.4.22:138 10.12.2.50:137 10.20.2.24:1027 10.12.2.44:138 10.12.2.44:137 10.0.4.38:58871 10.13.3.19:138 i need to separate the number out which is at the last and after ':' Please help me out Thanx in advance (5 Replies)
Discussion started by: vaibhavkorde
5 Replies

7. UNIX for Dummies Questions & Answers

creating separate directories according to file extension and keeping file in different directory as

unix program to which a directory name will be passed as parameter. This directory will contain files with various extensions. This script will create directories with the names of the extention of the files and then put the files in the corresponding folder. All files which do not have any... (2 Replies)
Discussion started by: Deekay.p
2 Replies

8. Shell Programming and Scripting

AWK to separate numbers from logs

Hello friends, Im trying to separate a number from a log, but it seems i need help here awk '/stimated/ {print $5}' mylog.txt gives (1515.45MB). i need pure number part to use in a comparision loop so i want to separate the number part (but only 1515 not 1515.45 ) awk '/stimated/... (6 Replies)
Discussion started by: EAGL€
6 Replies

9. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

10. UNIX for Dummies Questions & Answers

how to separate numbers and words from a file using shell scripts

Hi, How to separate numbers and words(with full alphabets) in a particular file and store it in two different files. Please help me out for this.Using shell scripting. :confused::confused: (1 Reply)
Discussion started by: kamakshi s
1 Replies
Login or Register to Ask a Question
RIG(6)								   Games Manual 							    RIG(6)

NAME
RIG - Random Identity Generator USAGE
rig [ -f | -m ] [ -d datadir ] [ -c num ] DESCRIPTION
Rig is a utility that will piece together a random first name, last name, street number and address, along with a geographically consistant (ie, they all match the same area) city, state, ZIP code, and area code. It is suitable for such applications as feeding the NY times registration page to fend off junk (snail) mail and telemarketers, or for reg- istering on BBS's to which you don't wish to reveal your real information. OPTIONS
-f, -m Respectively, use female and male names. If neither or both options are selected, RIG uses both female and male names. -d datadir Use data files found in datadir. Without this option, the default directory of /usr/share/rig is assumed. -c num Output num identities. Default is 1. FILES
/usr/share/rig/locdata.idx /usr/share/rig/street.idx /usr/share/rig/fnames.idx /usr/share/rig/mnames.idx /usr/share/rig/lnames.idx HISTORY
Based on "fake" written for MS-DOS. Unfortunately the author and publish date are unknown. First UNIX version written from scratch in 1999. This manpage based on RIG version 1.10. AUTHORS
UNIX version (c) 1999-2002 Ian Turner with contributions from Ian Prowell, Nick Rusnov, and Schneelocke. Geography Database is from the original version and I believe it to be held in the public domain. Names database is from the US Census at http://www.census.gov/genealogy/names/ , courtesy of Trent Stanley. Send all comments and bug-reports to: vectro@RIG.sourceforge.net 4 JUN 2002 RIG(6)