Text manipulation help required


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Text manipulation help required
# 1  
Old 10-23-2010
Text manipulation help required

Hi all, I want to perform different operations on text like converting string to lower, converting to upper, extract string etc.
can anyone suggest me shell commands for these?

is it possible to take input with read command and then applying perl commands for string manipulation?

Help me.
# 2  
Old 10-23-2010
sed, awk and tr are good starts for string manipulation in shell script.

You can take input into perl in 2 ways - first you read the string into a VAR:
Code:
read foo

Then you can either pass it into stdin:
Code:
echo $foo | ./myperlscript.pl

In which case you would then use something like this to read it in:
Code:
while (<STDIN>) {
print $_;
...
}

Or you can pass the variable in as a command line argument:
Code:
./myperlscript.pl $foo

In which case you would access it using:
Code:
print $ARGV[0];

I hope this makes things clearer
# 3  
Old 10-23-2010
If you have a recent bash : man bash
Code:
...
${parameter^pattern}
${parameter^^pattern}
${parameter,pattern}
${parameter,,pattern}
    Case  modification.   This  expansion modifies the case of alphabetic characters in parameter.  The pattern is expanded to
    produce a pattern just as in pathname expansion.  The ^ operator converts lowercase letters matching pattern to uppercase;
    the  , operator converts matching uppercase letters to lowercase.  The ^^ and ,, expansions convert each matched character
    in the expanded value; the ^ and , expansions match and convert only the first character in the expanded value..  If  pat‐
    tern  is  omitted,  it  is treated like a ?, which matches every character.  If parameter is @ or *, the case modification
    operation is applied to each positional parameter in turn, and the expansion is the resultant list.  If  parameter  is  an
    array  variable  subscripted  with @ or *, the case modification operation is applied to each member of the array in turn,
    and the expansion is the resultant list.
...

# 4  
Old 10-23-2010
Korn shell:
Code:
$ typeset -u bla=Hallo
$ echo $bla
HALLO
$ typeset -l bla=Hallo
$ echo $bla
hallo

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help text manipulation

Hello Forum , I need a help about text manupulation. I have a text file and I have to manipulate this file. Let's say source.txt source.txt UNB+UNOC:3+O0013000005MAN MN RVS:91+0098006688:92+190304:2313+F004169241' UNH+8146848+DELJIT:D:96A:UN' BGM+307:::JIS_SYNCRO_FIRM+2019030423234101+9'... (8 Replies)
Discussion started by: cemokam65
8 Replies

2. Shell Programming and Scripting

Text manipulation help

Hello again, I have a problem manipulating a large text document and there is no way I could edit this document by hand. Format is: Address : XXXX N 37 Ave, Hollywood, FL, 33021 Phone: XXX3190XXX Player: XXXXXX Character: Jaramillo DOB: June-14-1995 ----- Name: Alexandra Ticket... (3 Replies)
Discussion started by: galford
3 Replies

3. UNIX for Dummies Questions & Answers

Text manipulation

i want to generate a list line-by-line of normal characters using letters . for example : dnds gnos mgod pets jnfp etc... i want to use all letters with all the posibilities is there a script that can do this ? (3 Replies)
Discussion started by: suppliernr1
3 Replies

4. Shell Programming and Scripting

Text manipulation help

Hello Unix.com, How can i generate links like this: i got http://upload.com/1/1.txt and i need to generate links from http://upload.com/1/1.txt to http://upload.com/1000/1000.txt Thanks in advance, Galford D. Weller (4 Replies)
Discussion started by: galford
4 Replies

5. UNIX for Dummies Questions & Answers

text manipulation help

Hello unix.com How can I add in B file TEST as many lines as A file has. Example: test1.txt has 2320 lines ... how can I add the word TEST 2320 lines in test2.txt. its something like: cat test1.txt;while read x; .... (4 Replies)
Discussion started by: galford
4 Replies

6. UNIX for Dummies Questions & Answers

text manipulation help

Hello again unix.com How can I extract from a large file in format: steve@aol.com steve hawkins Location of this member is bla bla bla sun@hotmail.com Sun Ying This member is using browser bla bla bla to another text in format: steve@aol.com steve hawkins sun@hotmail.com sun ying ... (5 Replies)
Discussion started by: galford
5 Replies

7. UNIX for Dummies Questions & Answers

Text Manipulation Help

Hello unix.com, How can I sort a email list by domain name? Example how can I save only ".net" emails from a file? (1 Reply)
Discussion started by: galford
1 Replies

8. Shell Programming and Scripting

text manipulation

Hi All; i need to do text processing : I have a file: file1.txt >>>>>>>>>>>> 30 2 23 some 30 2 22 text 30 2 21 xyz 30 2 20 ttttt 30 2 19 ttttt-1 30 2 18 xryz 30 2 17 xyzr 30 2 16 xy111z 30 2 15 xanyyz 30 2 14 xzz 30 2 13 xyy 30 2 0 zzz-w 50 3 25 zzz-w 50 3 12 productw 50 3 10... (4 Replies)
Discussion started by: unlx
4 Replies

9. UNIX for Dummies Questions & Answers

text manipulation

I am tryin to figure out how to extract interested text from file example.txt blah blah blah a: child1 blah a: child2 blah b: parent1 blah blah blah .... blah a: child21 blah a: child22 blah a: child23 blah b: parent2 this kinda text repeats .. number of children is... (6 Replies)
Discussion started by: rajkishore
6 Replies

10. Shell Programming and Scripting

Text Manipulation.

Hi I have only ever used awk and sed for basic requirements up until now. I have had to break a log down for multiple purposes. Using awk, sed and a date script. I am left with this: (message id, time of msg attempt, message id, domain name, time of msg completion) ... (4 Replies)
Discussion started by: Icepick
4 Replies
Login or Register to Ask a Question