If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > how to read a file using shell ??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-16-07, 12:13
ranga2727 ranga2727 is offline
Registered User
 
Join Date: Sep 2007
Posts: 11
how to read a file using shell ??

Hello

i have a file in directory which has some values like this

lets assume the file is $p
ttry_rtyy_trree

and i am using a file as an input as ($Y) in a shell once i start the shell it should read the file $p and $Y once those lines are matched in $Y i want to take a copy of that line and lines which are below 7 lines and put it in a output file ($Z)
$Y has this
ttry_rtyy_trree
66341251111
14567888888
12323434343
23232454544
2323234354
354545476767
67676767676676
9834587957457439
100192903203239

and my Output file after extracting should be exactly like this

ttry_rtyy_trree
66341251111
14567888888
12323434343
23232454544
2323234354
354545476767

Thanks!!
Reply With Quote
  #2 (permalink)  
Old 09-18-07, 10:49
ranga2727 ranga2727 is offline
Registered User
 
Join Date: Sep 2007
Posts: 11
Thumbs up

can anyone help me on this ..
this is kinda urgent .. Here is the clear picture of what i need :

i have a mainfile (backup file) a.txt

and i have a constant file b.txt which will be added or deleted

lets assume i have the following contents in a.txt :

unix:workinshellscripting
samplethings
sample
condition
success
failure

unix:shell
cool
ice
work
place
history

and b.txt has
workinshellscripting

once i run the shell script it should read the param file and read the value in the backup files

and once the string is found it has to copy the contents (5 lines below) and paste it in an output file

hence my outputfile has these

unix:workinshellscripting
samplethings
sample
condition
success
failure
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On