Sponsored Content
Top Forums Shell Programming and Scripting Retrieve the first 9 digits from the numeric value Post 302210134 by fpmurphy on Monday 30th of June 2008 06:48:14 AM
Old 06-30-2008
And another way
Code:
#!/bin/ksh93

n=000000001200820060734
n=${n/*(0)({9}(\d))*(\d)/\2}
print $n

 

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
Path::Dispatcher::Cookbook(3pm) 			User Contributed Perl Documentation			   Path::Dispatcher::Cookbook(3pm)

NAME
Path::Dispatcher::Cookbook - A cookbook for Path::Dispatcher RECIPES
How can I change the path delimiter from a space ' ' to a slash '/'? When importing the Path::Dispatcher::Declarative sugar, specify the "token_delimiter" option for the "default" group. package My::Dispatcher; use Path::Dispatcher::Declarative -base, -default => { token_delimiter => '/', }; Or define a subclass of Path::Dispatcher::Declarative with a "token_delimiter" method: package Web::Dispatcher::Maker; use base 'Path::Dispatcher::Declarative'; use constant token_delimiter => '/'; package My::Dispatcher; use Web::Dispatcher::Maker -base; How can I do rule chaining (like in Catalyst)? You can use a "chain" rule approximate chaining behavior: package MyDispatcher; use Path::Dispatcher::Declarative -base; under show => sub { chain { print "Displaying "; }; on inventory => sub { print "inventory: "; ... }; on score => sub { print "score: "; ... }; }; package main; MyDispatcher->run("show inventory"); # "Displaying inventory: ..." MyDispatcher->run("show score"); # "Displaying score: ..." How can I configure tab completion for shells? First add a dispatcher rule for generating completions based on the path. Here we name it _gencomp, so that if the user types "app _gencomp hel" it will print out the various completions of "hel". on qr/^_gencomps*(.*)/ => sub { my $prefix = shift->pos(1); $prefix = "" if !defined($prefix); print "$_ " for dispatcher->complete($prefix); }; Then tell your shell about how to use _gencomp. For zsh it might look like this (replace "APP" with your binary name): /usr/share/zsh/site-functions/_APP: #compdef APP typeset -a APP_completions APP_completions=($($words[1] _gencomp $words[2,-1])) compadd $APP_completions For bash it might look like this: /etc/bash_completion.d/APP.bash: function _APP_() { COMPREPLY=($($1 _gencomp ${COMP_WORDS[COMP_CWORD]})) } complete -F _APP_ APP perl v5.12.4 2011-08-30 Path::Dispatcher::Cookbook(3pm)
All times are GMT -4. The time now is 06:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy