06-01-2002
Re: Extracting String from a list
Hi,
How about using
echo $line|tr -s " "|cut -d" " -f 3-
hope this solves the issue
rgds
penguin
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
How do I extract 5th to 10th characters of string as given below stored in a shell variable.
"ab cd ef gh ij kl"
How is cut to be used on this?
Thanks for any help. (1 Reply)
Discussion started by: preetikate
1 Replies
2. Shell Programming and Scripting
Hi all,
I have to extract only the second part of a database column (VARCHAR) and the value is seperated by a "~"
xyz~
chxyz36r~
abder~000082685
mnops~000083554
fulfil302~00026
Above are some examples of the values and for each record I have to extract the value after "~" , if there is a... (8 Replies)
Discussion started by: sam_78_nyc
8 Replies
3. Shell Programming and Scripting
Hi,
Need to extract a string from one file and search the same in other files.
Ex:
I have file1 of hundred lines with no delimiters not even space.
I have 3 more files.
I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
Discussion started by: mohancrr
1 Replies
4. Shell Programming and Scripting
Hi All,
I am writing a shell script for which I am stuck with an extraction part.
I arrived till extraction of a path of file. Lets take an example.
I now have a file which contains following one line:
2348/home/userid/mydir/any_num_dir/myfile.text
Now I want to extract only... (2 Replies)
Discussion started by: start_shell
2 Replies
5. Shell Programming and Scripting
I am trying to extract a hyperlink from a html document using awk. I have managed to output in the format... href="index.html"> where i would like it just to output index.html. Any ideas on how i would do this?
Thanks (2 Replies)
Discussion started by: adpe
2 Replies
6. Shell Programming and Scripting
Hello Everyone,
i have quick question.
I have file names like: bin_map300.asc and I would like to extract grid300.
My approach so far:
name=bin_map300.asc
echo ${name%%.*}
echo ${name##*_}
I am stuck combining the two.
Any help would be appreciated. (3 Replies)
Discussion started by: creamcheese
3 Replies
7. Shell Programming and Scripting
Hi ,
I have input file and i want to extract below strings
<msisdn xmlns="">0492001956</ msisdn> => numaber inside brackets
<resCode>3000</resCode> => 3000 needs to be extracted
<resMessage>Request time
getBalances_PSM.c(37): d out</resMessage></ns2:getBalancesResponse> => the word... (14 Replies)
Discussion started by: sushmab82
14 Replies
8. Shell Programming and Scripting
Hi Experts,
I am executing a script in bash profile and having file path as follows:
$FilePath=$HOST_NAME_LAND/home/chandan/abc.txt
where $HOST_NAME_LAND is an environment variable which points to the server name.
export $HOST_NAME_LAND=//<server name>
The environment variable name and... (6 Replies)
Discussion started by: ChandanN
6 Replies
9. Shell Programming and Scripting
I have a string:
2015-04-16 07:30:05,625000 +0900 xxxx.com
I just want to extract the time from the above line I am using the below syntax
x=~ /(.*) (\d+)\:(\d+)\:(\d+),(.*)\.com/
$time = $2 . ':' . $3 . ':' . $4;
print $time
But it is not working. Can some1 please help (2 Replies)
Discussion started by: karan8810
2 Replies
10. Shell Programming and Scripting
Hello.
First best wishes for everybody.
here is the input file ("$INPUT1") contents :
BASH_FUNC_message_begin_script%%=() { local -a L_ARRAY;
BASH_FUNC_message_debug%%=() { local -a L_ARRAY;
BASH_FUNC_message_end_script%%=() { local -a L_ARRAY;
BASH_FUNC_message_error%%=() { local... (3 Replies)
Discussion started by: jcdole
3 Replies
LEARN ABOUT DEBIAN
test::mocktime::datecalc
Test::MockTime::DateCalc(3pm) User Contributed Perl Documentation Test::MockTime::DateCalc(3pm)
NAME
Test::MockTime::DateCalc -- fake time for Date::Calc functions
SYNOPSIS
use Test::MockTime;
use Test::MockTime::DateCalc; # before Date::Calc loads
# ...
use My::Module::Using::Date::Calc;
DESCRIPTION
"Test::MockTime::DateCalc" arranges for the functions in "Date::Calc" to follow the Perl level "time" function (see perlfunc), and in
particular any fake date/time set there by "Test::MockTime". The following "Date::Calc" functions are changed
System_Clock
Today
Now
Today_and_Now
This_Year
Gmtime
Localtime
Timezone
Time_to_Date
"Gmtime", "Localtime", "Timezone" and "Time_to_Date" are made to default to the Perl-level current "time". When called with an explicit
time argument they're unchanged.
Module Load Order
"Test::MockTime" or similar fakery must be loaded first, before anything with a "time()" call, which includes "Test::MockTime::DateCalc".
This is the same as all "CORE::GLOBAL" overrides, see "OVERRIDING CORE FUNCTIONS" in CORE.
"Test::MockTime::DateCalc" must be loaded before "Date::Calc". If "Date::Calc" is already loaded then its functions might have been
imported into other modules and such imports are not affected by the redefinitions made. For that reason "Test::MockTime::DateCalc"
demands it be the one to load "Date::Calc" for the first time. Usually this simply means having "Test::MockTime::DateCalc" at the start of
a test script, before the things you're going to test.
use strict;
use warnings;
use Test::MockTime ':all';
use Test::MockTime::DateCalc;
use My::Foo::Bar;
set_fixed_time('1981-01-01T00:00:00Z');
is (My::Foo::Bar::something(), 1981);
restore_time();
In a test script it's often good to have your own modules early to check they correctly load their pre-requisites. You might want a
separate test script for that so you don't accidentally rely on "Test::MockTime::DateCalc" loading "Date::Calc" for you.
Other Faking Modules
"Test::MockTime::DateCalc" can be used with other modules which mangle the Perl-level "time" too. For example "Time::Fake",
use Time::Fake; # fakery first
use Test::MockTime::DateCalc;
Or "Time::Mock",
use Time::Mock; # fakery first
use Test::MockTime::DateCalc;
"Time::Warp" (as of version 0.5) only exports a new "time", it's not a core override and so can't be used with "Test::MockTime::DateCalc".
SEE ALSO
Date::Calc, Test::MockTime, Time::Fake, Time::Mock
faketime(1)
HOME PAGE
http://user42.tuxfamily.org/test-mocktime-datecalc/index.html
COPYRIGHT
Copyright 2009, 2010 Kevin Ryde
Test-MockTime-DateCalc is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at your option) any later version.
Test-MockTime-DateCalc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Test-MockTime-DateCalc. If not, see
<http://www.gnu.org/licenses/>.
perl v5.10.1 2010-09-15 Test::MockTime::DateCalc(3pm)