string processing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting string processing
# 1  
Old 03-24-2009
Java string processing

hi,

I have a string "satabeltodounixscriptingpleasecheckfortheerros"

in the above line if it contains "unix" , i need to take 5 characters after that word.

please help


thanks in advance
Satya
# 2  
Old 03-24-2009
Code:
 $ echo "satabeltodounixscriptingpleasecheckfortheerros" |sed 's/.*unix//g'|awk '{print substr($0,1,6)}'

script

Thanks
Sha
# 3  
Old 03-24-2009
no need for that extra awk process
Code:
echo "satabeltodounixscriptingpleasecheckfortheerros" |sed 's/.*unix\(.....\).*/\1/'

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Processing arguments in a string

Hi The following code works when reading the arguments from the command line but fails when I try to read from a string. So this works while ; do case $1 in -dbversion) if '`" ]; then { echo "ERROR: missing value for '$1' (seen '$2')"; usage; exit 1; } else { shift;... (6 Replies)
Discussion started by: user052009
6 Replies

2. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

3. Shell Programming and Scripting

Processing 1 match string from grep at a time

hi all, i have a few log files with dates that are incorrrect (please don't ask me why). i need to add 2852 days, 16 hours, and 21 minutes (246471660 seconds) to each of these dates to correct them. i need to write to new "test2.txt" file that corrects the dates found by grep and yet have it... (4 Replies)
Discussion started by: cilantrocado
4 Replies

4. Shell Programming and Scripting

[Python]StringVar() Class String processing

I have a requirement where I collect inputs from entry widget in gui(via variables a,b,c) and then output a string like this: -a a -b b -c c. Hence if I have given a=1 b=2 c=3, The output string is --> -a 1 -b 2 -c 3 or if I have given a=1 b=2 (c left blank) then the output is --> -a 1... (1 Reply)
Discussion started by: animesharma
1 Replies

5. Shell Programming and Scripting

[string processing]Adding new line in file

I have a report file which somewhere has a lines starting with word ".sub" I have a new variable named $new. What i am trying to do is insert the content of $new just before the occurrence of ".sub" in the report file. How can I do that? (11 Replies)
Discussion started by: animesharma
11 Replies

6. Shell Programming and Scripting

String processing in CSH

Please delete it (0 Replies)
Discussion started by: animesharma
0 Replies

7. Shell Programming and Scripting

String processing to compare dates

Hi all, I have been scripting a shell script to allow me to easily create htaccess users and add them to existing htaccess groups etc. However, the main part of the script that I am trying to accomplish is to store additional metadata in comments in the htpasswd file. I am trying to store an... (8 Replies)
Discussion started by: joshuaspence
8 Replies

8. Shell Programming and Scripting

Appending string to match pattern (data processing)

Hello i have go the following result from performing 2 testing using the same file. I have used unix script to extract the result because the files are many as shown below. 01_gravity.f.tcov 7 3 42.86 02_gravity.f.tcov 9 4 80.86... (4 Replies)
Discussion started by: ganiel24
4 Replies

9. UNIX for Dummies Questions & Answers

String Processing

I had a file with 150k records in it and I ran a tr on it to remove all new lines/CR which created one large record(whoops). Is there a way to add a \n after every 39th character without using 'dd' to turn it back into the original format? dd is way to slow. shell is ksh. (1 Reply)
Discussion started by: bthomas
1 Replies
Login or Register to Ask a Question