I like the solution from aigles. I don't see one yet on perl.
The perl RE syntax has special features for the shortest match. Here is the entire code, along with diagnostic code, minimal argument processing, etc:
Running this on your test line and a few others in file data1:
The heart of the match is in these characters .*?
See the man pages for:
for details ... cheers, drl
i am a new user of C-shell script.
I want to know can i create a substring in a string.
That means when i got a variable $input = "it is number 2"
I want to get the "2" to be another variable.
Can i do that in C-shell and how to ?
Thank you so much
dinodash (0 Replies)
hi all, I have read similiar topics in this board, but i didn' t find the posting which is the same with the problem i face.. I try to extract string from the end. i try to do this:
num=abcdefghij
num2=${num:-5}
echo $num2 #this should print the last 5 characters (fghij)
but it doesn;t... (3 Replies)
Hi
I'm new to Shell scripting. Someone please help me in extracting a portion of string from a file.
Eg:
I got a file like, Readme.txt and has the following name value pairs
input1 : /homes/input1/
input2 : /homes/input2/
...
...
When I give the parameter input1, the value... (3 Replies)
please give me proper solution for finding a shortest substring from given string if string itself and first char and last char of that substr are also given by user
if S="dpoaoqooroo" and FC="o" and LC="o",then shortest substr is "oo" and rest of the string is "dpoaoqroo"
i have code but it is... (1 Reply)
Hi All,
This is Ram. I'm new to this forum & new to shell scripts as well. I've a requirement in which I want to extract a substring from a given string based on last occurance of a character.
for eg.
I have a string of a file name with absolute path like... (2 Replies)
I need a help in getting substring of each line in input file.
I am writing a script that will read a file from a directory on daily basis, I mean everyday a new file will be stored in this directory, it will replace old file. I have to read contents of this file, the contents will be as... (5 Replies)
This is the data I am having in a file
Just for sample I have given 3 records. The file which I am having consists of n number of records.
ABC123 10 01/02/2008 2008-01-03-00.00.00.000000
DYUU 22 02/03/2008 2008-01-04-00.00.00.000000
RF33 88 03/05/2008 2008-01-05-00.00.00.000000
... (24 Replies)
hi
i need to name a file with a substring of a another file name.
i.e. if the old filename is abc.txt , the new filename should be abc_1.txt
i should get the substring of the file name and then name the new one
please let me know how to do it (4 Replies)
Hi awk and sed gurus,
Please help me in the following.
I have the following entries in the file
ABCDErules
AbHDPrules
ABCrules
--
--
and other entries in the file.
Now, I want to extract from the file that contain entries for *rules and process it separately.
How can i do it... (6 Replies)
Hi,
I have string in variable like '/u/dolfin/in/DOLFIN.PRL_100.OIB.TLU.001.D20110520.T040010'
and i want to conevrt this string into only "DOLFIN.PRL_100.OIB.TLU.001.D20110520.T040010" (i.e file name).
Is there any command to extracting string in some part ?(rather than whole path)?
... (5 Replies)
Discussion started by: shyamu544
5 Replies
LEARN ABOUT DEBIAN
viewperl
VIEWPERL(1) User Commands VIEWPERL(1)NAME
viewperl - quickly view syntax highlighted Perl code
SYNOPSIS
viewperl [OPTION]... FILE...
DESCRIPTION
View a Perl source code file, syntax highlighted.
-c, --code=CODE
view CODE, syntax highlighted
-l, --lines
display line numbers
-L, --no-lines
supress display of line numbers (default)
-m, --module=FILE
consider FILE the name of a module, not a file name
-n, --name
display the name of each file (default)
-N, --no-name
supress display of file names (implied by --no-reset)
-p, --pod
display inline POD documentation (default)
-P, --no-pod
hide POD documentation (line numbers still increment)
-r, --reset
reset formatting and line numbers each file (default)
-R, --no-reset
supress resetting of formatting and line numbers
-s, --shift=WIDTH
set tab width (default is 4)
-t, --tabs
translate tabs into spaces (default)
-T, --no-tabs
supress translating of tabs into spaces
--help display this help and exit
Note that module names should be given as they would appear after a Perl `use' or `require' statement. `Getopt::Long', for example.
Each string given using -c is considered a different file, so line number and formatting resets will apply.
View a Perl source code file, syntax highlighted.
-c, --code=CODE
view CODE, syntax highlighted
-l, --lines
display line numbers
-L, --no-lines
supress display of line numbers (default)
-m, --module=FILE
consider FILE the name of a module, not a file name
-n, --name
display the name of each file (default)
-N, --no-name
supress display of file names (implied by --no-reset)
-p, --pod
display inline POD documentation (default)
-P, --no-pod
hide POD documentation (line numbers still increment)
-r, --reset
reset formatting and line numbers each file (default)
-R, --no-reset
supress resetting of formatting and line numbers
-s, --shift=WIDTH
set tab width (default is 4)
-t, --tabs
translate tabs into spaces (default)
-T, --no-tabs
supress translating of tabs into spaces
--help display this help and exit
Note that module names should be given as they would appear after a Perl `use' or `require' statement. `Getopt::Long', for example.
Each string given using -c is considered a different file, so line number and formatting resets will apply.
viewperl August 2007 VIEWPERL(1)