![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need to insert new text and change existing text in a file using SED | iamgeethuj | Shell Programming and Scripting | 4 | 11-25-2008 03:59 AM |
| How to insert some constant text at beginig of each line within a text file. | Muhammad Afzal | Shell Programming and Scripting | 4 | 10-30-2008 11:01 PM |
| insert text into column | knoxo | Shell Programming and Scripting | 1 | 03-31-2008 06:01 AM |
| how to insert text using variable | mopimp | Shell Programming and Scripting | 1 | 03-24-2006 08:32 PM |
| Insert Text With Sed | steveramsey | UNIX for Dummies Questions & Answers | 5 | 02-09-2006 09:48 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Insert text below other text
I need help in bash.
This is the problem I have a php file that I edit, add a line under another. PHP file: <select name="RecPerPage" id="RecPerPage" onchange="this.form.submit();" class="phpmaker"> <option value="50">Select version</option> </select> I need insert "<option value="anything">Select version1</option>" below "<option value="50">Select version</option>" Please help me... I tried for a long time but not get anything |
|
||||
|
I'm using gedit editor and working on bash(sh files)
Sorry for my english. My language is Spanish ![]() ---------- Post updated at 08:15 PM ---------- Previous update was at 08:02 PM ---------- I tried this: sed '/^<option value="50">Seleccione una version...</option>/<option value="50">Select version</option>' file > newfile but the bash interpret leaves no place < or > or / in the text to insert. I think it is confused with bash syntaxis. |
|
||||
|
Suponiendo que "file.txt" tiene el siguiente contenido: Code:
leo@lein:~/Escritorio$ cat "file.txt" <select name="RecPerPage" id="RecPerPage" onchange="this.form.submit();" class="phpmaker"> <option value="50">Select version</option> </select> leo@lein:~/Escritorio$ Y tengo un script "shell.sh" con el siguiente contenido: Code:
#!/usr/bin/bash cat file.txt | sed '/option value/ a\ <option value="anything">Select version1</option>' Ahora ejecutandolo: Code:
leo@lein:~/Escritorio$ bash shell.sh <select name="RecPerPage" id="RecPerPage" onchange="this.form.submit();" class="phpmaker"> <option value="50">Select version</option> <option value="anything">Select version1</option> </select> leo@lein:~/Escritorio$ Solo redirigelo: Code:
leo@lein:~/Escritorio$ bash shell.sh > nuevo.txt leo@lein:~/Escritorio$ cat nuevo.txt <select name="RecPerPage" id="RecPerPage" onchange="this.form.submit();" class="phpmaker"> <option value="50">Select version</option> <option value="anything">Select version1</option> </select> leo@lein:~/Escritorio$ Saludos. O solo: Code:
sed '/option value/ a\<option value="anything">Select version1</option>' "file.txt" |
|
||||
|
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|