10 More Discussions You Might Find Interesting
1. UNIX for Beginners Questions & Answers
Hello Everyone ,
Iam a newbie to shell programming and iam reaching out if anyone can help in this :-
I have two files
1) Insert.txt
2) partition_list.txt
insert.txt looks like this :-
insert into emp1 partition (partition_name)
(a1,
b2,
c4,
s6,
d8)
select
a1,
b2,
c4, (2 Replies)
Discussion started by: nubie2linux
2 Replies
2. Shell Programming and Scripting
Hi ,
I am writing a shell script to check pvsizes in linux box.
# for i in `cat vgs1`
> do
> echo "########### $i ###########"
> pvs|grep -i $i|awk '{print $2,$1,$5}'>pvs_$i
> pvs|grep -i $i|awk '{print $1}'|while read a
> do
> fdisk -l $a|head -2|tail -1|awk '{print $2,$3}'>pvs_$i1
>... (3 Replies)
Discussion started by: nanduri
3 Replies
3. UNIX for Dummies Questions & Answers
hi gurus,
I'm executing some commands and I want to append both the command and output to a text file. Example:
echo "strings -a wicmex.o|grep '$Header'" >> tmp.txt
strings -a wicmex.o|grep '$Header' >> tmp.txt
echo "strings -a libwip.a|grep '$Header'" >> tmp.txt
strings -a libwip.a|grep... (1 Reply)
Discussion started by: donisback
1 Replies
4. Shell Programming and Scripting
The question is not as simple as the title... I have a file, it looks like this
<string name="string1">RZ-LED</string>
<string name="string2">2.0</string>
<string name="string2">Version 2.0</string>
<string name="string3">BP</string>
I would like to check for duplicate entries of... (11 Replies)
Discussion started by: raidzero
11 Replies
5. Shell Programming and Scripting
I have a 13 number string, some whitespace, and then /mp3.
I need to join them. Everyline that I need this for begins with "cd" (without the quotes).
What it looks like now:
cd media/Audio/WAVE/9781933976334 /mp3 What I want my output to be:
cd media/Audio/WAVE/9781933976334/mp3 The 13... (7 Replies)
Discussion started by: glev2005
7 Replies
6. Shell Programming and Scripting
Hi
Following is an example line.
echo "192.22.22.22 \"33dffwef\" 200 300 dsdsd" | sed "s:\(\ *\ \):\1:"
I want it's output to be
200
However this is not the case. Can you tell me how to do it? I don't want to use AWK for this. Secondly, how can i fetch just 300? Should I use "\2"... (3 Replies)
Discussion started by: shahanali
3 Replies
7. Shell Programming and Scripting
I would like to append the numbers 1, 2, 3, 4 and so on to the lines of the file:
Adam Wilkins | Colorado | 36
John Butler | Los Angeles | 47
Cassey Johnson | Minneapolis | 25
Albert Aniston | Miami | 19
....
Tony Legler | Sacramento | 55
Matt Simmons | New York | 38
Output would look... (4 Replies)
Discussion started by: xinoo
4 Replies
8. Shell Programming and Scripting
Greetings all,
I'm in need of some help in coming up with this command which requires me to append 5 strings together:
1. echo "Status from system:"
2. `cat logs.txt` (i need the output of this command)
3. echo "Error output: "
4. `cat errors.txt`(i need the output of this command)
5.... (3 Replies)
Discussion started by: rockysfr
3 Replies
9. UNIX for Dummies Questions & Answers
HI,
Supose I have the folowing strings: "unix" and "linux". I want to concatenate the two strings, inserting between them a variable number of spaces.
ex1: unix linux
ex2: unix linux
Can you help me in this simple problem?
Regards,
Elio (2 Replies)
Discussion started by: efernandes
2 Replies
10. UNIX for Dummies Questions & Answers
Hi
I am looping through the contents of a file as follows
cat file |while read inrec
do
echo $inrec >> $TMP
done
(obviously this isn't all i am doing as it would be pointless but for the sake of the problem this is the important bit)
The file has fields which are separated by... (1 Reply)
Discussion started by: handak9
1 Replies
Text::Trim(3pm) User Contributed Perl Documentation Text::Trim(3pm)
NAME
Text::Trim - remove leading and/or trailing whitespace from strings
VERSION
version 1.02
SYNOPSIS
use Text::Trim;
$text = " important data
";
$data = trim $text;
# now $data contains "important data" and $text is unchanged
# or:
trim $text; # work in-place, $text now contains "important data"
@lines = <STDIN>;
rtrim @lines; # remove trailing whitespace from all lines
# Alternatively:
@lines = rtrim <STDIN>;
# Or even:
while (<STDIN>) {
trim; # Change $_ in place
# ...
}
DESCRIPTION
This module provides functions for removing leading and/or trailing whitespace from strings. It is basically a wrapper around some simple
regexes with a flexible context-based interface.
EXPORTS
All functions are exported by default.
CONTEXT HANDLING
void context
Functions called in void context change their arguments in-place
trim(@strings); # All strings in @strings are trimmed in-place
ltrim($text); # remove leading whitespace on $text
rtrim; # remove trailing whitespace on $_
No changes are made to arguments in non-void contexts.
list context
Values passed in are changed and returned without affecting the originals.
@result = trim(@strings); # @strings is unchanged
@result = rtrim; # @result contains rtrimmed $_
($result) = ltrim(@strings); # like $result = ltrim($strings[0]);
scalar context
As list context but multiple arguments are stringified before being returned. Single arguments are unaffected. This means that under
these circumstances, the value of $" ($LIST_SEPARATOR) is used to join the values. If you don't want this, make sure you only use single
arguments when calling in scalar context.
@strings = (" hello
", " there
");
$trimmed = trim(@strings);
# $trimmed = "hello there"
local $" = ', ';
$trimmed = trim(@strings);
# Now $trimmed = "hello, there"
$trimmed = rtrim;
# $trimmed = $_ minus trailing whitespace
Undefined values
If any of the functions are called with undefined values, the behaviour is in general to pass them through unchanged. When stringifying a
list (calling in scalar context with multiple arguments) undefined elements are excluded, but if all elements are undefined then the return
value is also undefined.
$foo = trim(undef); # $foo is undefined
$foo = trim(undef, undef); # $foo is undefined
@foo = trim(undef, undef); # @foo contains 2 undefined values
trim(@foo) # @foo still contains 2 undefined values
$foo = trim('', undef); # $foo is ''
FUNCTIONS
trim
Removes leading and trailing whitespace from all arguments, or $_ if none are provided.
rtrim
Like trim() but removes only trailing (right) whitespace.
ltrim
Like trim() but removes only leading (left) whitespace.
UNICODE
Because this module is implemented using perl regular expressions, it is capable of recognising and removing unicode whitespace characters
(such as non-breaking spaces) from scalars with the utf8 flag on. See Encode for details about the utf8 flag.
Note that this only applies in the case of perl versions after 5.8.0 or so.
SEE ALSO
Brent B. Powers' String::Strip performs a similar function in XS.
AUTHOR
Matt Lawrence <mattlaw@cpan.org>
ACKNOWLEDGEMENTS
Terrence Brannon <metaperl@gmail.com> for bringing my attention to String::Strip and suggesting documentation changes.
perl v5.10.1 2010-06-07 Text::Trim(3pm)