![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help with finding & replacing pattern in a file | dusoo | Shell Programming and Scripting | 0 | 05-23-2008 12:59 AM |
| Replacing more than 1 pattern in a line | Manan | Shell Programming and Scripting | 6 | 12-27-2006 10:58 PM |
| Replacing a paragraph between pattern , with the content 4m another file | go4desperado | Shell Programming and Scripting | 4 | 12-07-2006 06:44 AM |
| Search file for pattern and grab some lines before pattern | frustrated1 | Shell Programming and Scripting | 2 | 12-22-2005 12:41 PM |
| Replacing pattern in variable | videsh77 | Shell Programming and Scripting | 1 | 05-26-2005 11:11 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
replacing a pattern in a file
Hi guys,
i have a pattern that i am searching in a file and i want to extract some of this pattern ... module TS1N65ULPA96X32M4 ( .... i want to extract only TS1N65ULPA96X32M4 part and i do the following sed 's/module \([a-z0-9]x[a-z0-9]*\).*/\1/' name_of_file but this is not quite right. could someone help me to do the above. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
i forgot to ask another question related to this one,
how could i replaced the number 96 and 32 within TS1N65ULPA96X32M4 with some variables that i have. i was wondering if i could use something like sed 's/ TS1N65ULPA96X32M4/ TS1N65ULPA$VARIABLE1X$VARIABLE2M4/' but this obviously does not work could someone help me with this one too. i posted the two questions here because they are relevant to each other |
|
#3
|
||||
|
||||
|
Quote:
Code:
sed "s/ TS1N65ULPA96X32M4/ TS1N65ULPA${VARIABLE1}X${VARIABLE2}M4/" input_file.txt
|
|
#4
|
|||
|
|||
|
Quote:
i hope i will get an answer for the first question too |
|
#5
|
||||
|
||||
|
I didn't understand very well your first problem or, at least, what's its relation with the second
Anyway, with sed: Code:
sed "/module/s/^.* \(.*\) .*$/\1/" input_file.txt Code:
awk '/module/ { print $2 }' input_file.txt
|
|
#6
|
|||
|
|||
|
Thanks for your help it work just fine but i replaced " with ' .
|
|
#7
|
|||
|
|||
|
Quote:
I think i was not clear with this question,so I am going to try to explain it again: i have a file which contains a verilog code. this verilog code contain the following line at some point: .......................... ...................the begining of the code ..... module TS1N65ULPA256X16M4 ( CLK, CEB, WEB, A, D, BWEB, Q, TSEL ); .......the rest of the code i am interested in TS1N65ULPA256X16M4 which appears after module and before (. i was wondering how to extract TS1N65ULPA256X16M4. could someone please help me with this |
|||
| Google The UNIX and Linux Forums |