Sponsored Content
Top Forums Shell Programming and Scripting extract a field from a long sentence! Post 302506896 by kato on Tuesday 22nd of March 2011 07:53:51 AM
Old 03-22-2011
If you just want the value you could use sed:

Code:
sed 's/.*LENGTH *="\([0-9]*\).*/\1/' file

Move the left bracket if you want to include LENGTH =
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Subtract 100 from first field in long list? Simple manipulation?

It sounds so easy to do. I have a file thats laid out like this.. number text text text text (etc about 15 times with various text fields) I want to take the first field, "number", subtract 100 from it, and then put it back in the file. a simple little manipulation of the first field in... (4 Replies)
Discussion started by: LordJezo
4 Replies

2. Shell Programming and Scripting

Trim leading zeros to make field 6 characters long

Hi all- I've got a file that will have multiple columns. In one column there will be a string that is 10 digits in length, but I need to trim the first four zeros to make it 6 characters? example: 0000001234 0000123456 0000234566 0000000321 output: 001234 123456 234566 000321 (5 Replies)
Discussion started by: Cailet
5 Replies

3. UNIX for Dummies Questions & Answers

Script to ask for a sentence and then count number of spaces in the sentence

Hi People, I need some Help to write a unix script that asks for a sentence to be typed out then with the sentence. Counts the number of spaces within the sentence and then echo's out "The Number Of Spaces In The Sentence is 4" as a example Thanks Danielle (12 Replies)
Discussion started by: charlie101208
12 Replies

4. Shell Programming and Scripting

Trim the sentence containing colon and period to extract a word in between

Hello All , i am a newbie in korn shell scripting trying to trim a sentence that is parsed into a variable . The format of the sentence has three words that are separated from other by a " : " colon and "." period . Format of the sentence looks like ... (5 Replies)
Discussion started by: venu
5 Replies

5. Shell Programming and Scripting

extract from a long sentence

Hi, There's a long sentence from which I need to extract only the part which is at the right side of the word LENGTH i.e. 15 long sentence : <INPUT VAR1 ="" DATATYPE ="number(p,s)" VAR2 ="" VAR3 ="3" VAR4="0" VAR5 ="ELEMITEM" VAR6 ="NO" VAR7 ="NOT A KEY" VAR8 ="17" LEVEL ="0" NAME... (3 Replies)
Discussion started by: dips_ag
3 Replies

6. Shell Programming and Scripting

Extract a word from sentence

$SET_PARAMS='-param Run_Type_Parm=Month -param Portfolio_Parm="997" -param From_Date_Parm="2011-08-09"' Want to extract the value of "Portfolio_Parm" from $SET_PARAMS i.e in the above case "997" & assigned to new variable. The existence order of "Portfolio"Parm" can change, but the name... (2 Replies)
Discussion started by: SujeethP
2 Replies

7. Shell Programming and Scripting

Multiple long field separators

How do I use multiple field separators in awk? I know that if I use awk -F"", both a and b will be field separators. But what if I need two field separators that both are longer than one letter? If I want the field separators to be "ab" and "cd", I will not be able to use awk -F"". The ... (2 Replies)
Discussion started by: locoroco
2 Replies

8. Shell Programming and Scripting

Extract sentence and its details from a text file based on another file of sentences

Hi I have two text files. The first file is TEXTFILEONE.txt as given below: <Text Text_ID="10155645315851111_10155645333076543" From="460350337461111" Created="2011-03-16T17:05:37+0000" use_count="123">This is the first text</Text> <Text Text_ID="10155645315851111_10155645317023456"... (7 Replies)
Discussion started by: my_Perl
7 Replies

9. Shell Programming and Scripting

How to extract only relevant part from a sentence?

Hello All, I have a file with details such as below. How do i extract only the host and port ? eg: dbs.ads.com 1521 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbs.ads.com)(PORT=1521))(CONNECT_DATA=(SID=vug)))... (5 Replies)
Discussion started by: JohnJacobChacko
5 Replies

10. Programming

SQL issues comparing Long field to sysdate

I am having hard time with this sql: select partition_name, high_value FROM user_tab_partitions WHERE table_name = 'WNP_TPRESPONSE_INSTANCE' and to_char(high_value) <= to_char(sysdate - 15, 'yyyymm') ; I get an error: ORA-00932: inconsistent datatypes: expected CHAR got LONG... (1 Reply)
Discussion started by: mrn6430
1 Replies
Scalar(3pm)						User Contributed Perl Documentation					       Scalar(3pm)

NAME
Test::Data::Scalar -- test functions for scalar variables SYNOPSIS
use Test::Data qw(Scalar); DESCRIPTION
This modules provides a collection of test utilities for scalar variables. Load the module through Test::Data. Functions blessed_ok( SCALAR ) Ok if the SCALAR is a blessed reference. defined_ok( SCALAR ) Ok if the SCALAR is defined. undef_ok( SCALAR ) Ok if the SCALAR is undefined. dualvar_ok( SCALAR ) Ok if the scalar is a dualvar. How do I test this? sub dualvar_ok ($;$) { my $ok = Scalar::Util::dualvar( $_[0] ); my $name = $_[1] || 'Scalar is a dualvar'; $Test->ok( $ok, $name ); $Test->diag("Expected a dualvar, didn't get it ") unless $ok; } greater_than( SCALAR, BOUND ) Ok if the SCALAR is numerically greater than BOUND. length_ok( SCALAR, LENGTH ) Ok if the length of SCALAR is LENGTH. less_than( SCALAR, BOUND ) Ok if the SCALAR is numerically less than BOUND. maxlength_ok( SCALAR, LENGTH ) Ok is the length of SCALAR is less than or equal to LENGTH. minlength_ok( SCALAR, LENGTH ) Ok is the length of SCALAR is greater than or equal to LENGTH. number_ok( SCALAR ) Ok if the SCALAR is a number ( or a string that represents a number ). At the moment, a number is just a string of digits. This needs work. number_between_ok( SCALAR, LOWER, UPPER ) Ok if the number in SCALAR sorts between the number in LOWER and the number in UPPER, numerically. If you put something that isn't a number into UPPER or LOWER, Perl will try to make it into a number and you may get unexpected results. string_between_ok( SCALAR, LOWER, UPPER ) Ok if the string in SCALAR sorts between the string in LOWER and the string in UPPER, ASCII-betically. readonly_ok( SCALAR ) Ok is the SCALAR is read-only. ref_ok( SCALAR ) Ok if the SCALAR is a reference. ref_type_ok( REF1, REF2 ) Ok if REF1 is the same reference type as REF2. strong_ok( SCALAR ) Ok is the SCALAR is not a weak reference. tainted_ok( SCALAR ) Ok is the SCALAR is tainted. (Tainted values may seem like a not-Ok thing, but remember, when you use taint checking, you want Perl to taint data, so you should have a test to make sure it happens.) untainted_ok( SCALAR ) Ok if the SCALAR is not tainted. weak_ok( SCALAR ) Ok if the SCALAR is a weak reference. TO DO
* add is_a_filehandle test * add is_vstring test SEE ALSO
Scalar::Util, Test::Data, Test::Data::Array, Test::Data::Function, Test::Data::Hash, Test::Builder SOURCE AVAILABILITY
This source is in Github: http://github.com/briandfoy/test-data/tree/master AUTHOR
brian d foy, "<bdfoy@cpan.org>" COPYRIGHT AND LICENSE
Copyright (c) 2002-2009 brian d foy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2009-02-12 Scalar(3pm)
All times are GMT -4. The time now is 05:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy