Sponsored Content
Top Forums Shell Programming and Scripting Retrieve the first 9 digits from the numeric value Post 302210065 by zaxxon on Monday 30th of June 2008 04:18:20 AM
Old 06-30-2008
All in one sed:
Code:
sed 's/^0*\(.\{9\}\).*/\1/g'

Your example works:
Code:
000000001200820060734
        ^^^^^^^^^

## If number of didigts in front changes, ie. if the last leading zero is not a prefix:
000000000200820060734
         ^^^^^^^^^

So this can go wrong and you might want to use the following, based on a fix number/position of digits:
Code:
echo "000000001200820060734"| cut -c8-17


Last edited by zaxxon; 06-30-2008 at 05:31 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to cut last 10 digits off

Hi I'm new to this. I need to cut off the last 10 digits from a line. I've used awk {'print $4'} filename.txt | cut -c 32-42 but this does not guarantee only the last 10 characters. Please help. Thanks. Sara (4 Replies)
Discussion started by: psarava
4 Replies

2. Shell Programming and Scripting

Perl code to differentiate numeric and non-numeric input

Hi All, Is there any code in Perl which can differentiate between numeric and non-numeric input? (11 Replies)
Discussion started by: Raynon
11 Replies

3. Shell Programming and Scripting

Formatting digits

I want to check the argument in KSH. If the user type in the prompt 'find 3' it will format 3 to 003 to match the data in the text file. Same as with 10 to 010. Always begins with 0. eg. >find 3 Output: 003 >find 30 Output: 030 (7 Replies)
Discussion started by: harry0013
7 Replies

4. Shell Programming and Scripting

total last digits

hi group, How can I count total number of 5's which are continuous in the end. i.e. in the below string, the o/p should be 4 I just know to calculate total number of 5's $ echo "95952325555" | awk -F "5" '{print NF-1}' 6 (3 Replies)
Discussion started by: uwork72
3 Replies

5. Shell Programming and Scripting

help: single digits inflated to 2 digits

Hi Folks Probably an easy one here but how do I get a sequence to get used as mentioned. For example in the following I want to automatically create files that have a 2 digit number at the end of their names: m@pyhead:~$ for x in $(seq 00 10); do touch file_$x; done m@pyhead:~$ ls file*... (2 Replies)
Discussion started by: amadain
2 Replies

6. UNIX for Dummies Questions & Answers

Find and Replace random numeric value with non-numeric value

Can someone tell me how to change the first column in a very large 17k line file from a random 10 digit numeric value to a non numeric value. The format of lines in the file is: 1702938475,SNU022,201004 the first 10 numbers always begin with 170 (6 Replies)
Discussion started by: Bahf1s
6 Replies

7. Shell Programming and Scripting

Find filenames with three digits and add zeros to make five digits

Hello all! I've looked all over the internet and this site and have come up a loss with an easy way to make a bash script to do what I want to do. I have a file with a naming convention as follows: 2012-01-18 string of words here 123.jpg 2012-01-18 string of words here 1234.jpg 2012-01-18... (2 Replies)
Discussion started by: Buzzman25
2 Replies

8. Programming

6 digits combination

Is there any program that can create 6 digit numbers with: (DIGIT_1)+(DIGIT_2)+(DIGIT_3)+(DIGIT_4)+(DIGIT_5)+(DIGIT_6)=10 Any perl or C also can. Anyone can help me? Thank you (6 Replies)
Discussion started by: Tzeronone
6 Replies

9. Shell Programming and Scripting

Showing 4 digits

Hello everybody I'm a little beginer for shell script as I started last night... I have this script cat fichier.txt | while read l ; do #echo $l echo $x x=$(( $x + 1 )) done it's return 1 2 3 4 (4 Replies)
Discussion started by: remibemol
4 Replies

10. UNIX for Beginners Questions & Answers

sed / awk script to delete the two digits from first 3 digits

Hi All , I am having an input file as stated below 5728 U_TOP_LOGIC/U_CM0P/core/u_cortexm0plus/u_top/u_sys/u_core/r03_q_reg_20_/Q 011 611 U_TOP_LOGIC/U_CM0P/core/u_cortexm0plus/u_top/u_sys/u_core/r04_q_reg_20_/Q 011 3486... (4 Replies)
Discussion started by: kshitij
4 Replies
Dialcodes(4)						     Kernel Interfaces Manual						      Dialcodes(4)

NAME
Dialcodes - Contains the initial digits of telephone numbers used to establish remote connections over a telephone line SYNOPSIS
/usr/lib/uucp/Dialcodes DESCRIPTION
The /usr/lib/uucp/Dialcodes file contains the initial digits of telephone numbers used by the uucp program to establish remote connections over a telephone line. The Dialcodes file simplifies entries in the /usr/lib/uucp/Systems file for sites where a number of device tele- phone numbers have the same prefix. If users at your site communicate regularly by way of telephone lines and modems to multiple systems all located at the same remote site, or to multiple systems located at different remote sites, use dial-code abbreviations in the /usr/lib/uucp/Systems file rather than entering the complete telephone number of each remote modem in that file. The Dialcodes file contains dial-code abbreviations and partial telephone numbers that complete the telephone entries in the /usr/lib/uucp/Systems file. Entries in the Dialcodes file contain an alphabetic prefix attached to a partial telephone number that may include the following information, in the order listed: Codes for an outside line. Long-distance access codes (1 and the area code, if the modem is out of the local area). The 3-digit exchange number. The relevant alphabetic prefix (representing the partial telephone number), together with the remaining four digits of that number, is then entered in the Phone field in the /usr/lib/uucp/Systems file. Following is the form of an entry in a Dialcodes file: DialCodeAbbreviation DialingSequence The DialCodeAbbreviation part of the entry is an alphabetic prefix containing up to eight letters, established when setting up the dial- code listing. The DialingSequence comprises all the digits in the number that precede the actual 4-digit telephone number. Note that if your site uses only a relatively small number of telephone connections to remote systems, include the complete telephone num- bers of the remote modems in the /usr/lib/uucp/Systems file rather than using dial-code abbreviations. Enter each prefix only once in the Dialcodes file. When you have set up a dial-code abbreviation, use that prefix in all relevant entries in the /usr/lib/uucp/Systems file. Only someone with superuser authority can edit the Dialcodes file, which is owned by the uucp program login ID. EXAMPLES
The Dialcodes file on system venus contains the following dial-code prefix for use with a number in the /usr/lib/uucp/Systems file: local 9=555 The Systems file on system venus contains the following entry for system zeus, including a telephone number and a dial-code prefix: zeus Any ACU 1200 local1212 in:--in: nuucp word: thunder When the uucp program on system venus dials system zeus, it uses the expanded telephone number =5551212. FILES
Contains all the configuration files for the uucp program, including the Dialcoddes file Contains information about available devices Spec- ifies initial handshaking on a connection Describes accessible remote systems RELATED INFORMATION
Commands: cu(1), tip(1), uucp(1), uuto(1), uux(1) delim off Dialcodes(4)
All times are GMT -4. The time now is 10:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy