Sponsored Content
Top Forums Shell Programming and Scripting Edit lines in file preserving part of it Post 303041333 by Cacializ on Thursday 21st of November 2019 12:31:30 PM
Old 11-21-2019
Edit lines in file preserving part of it

Hello:
I have the following HTML table:
Code:
<table>
    <thead>
        <tr>
            <th>Code</th>
            <th>Percentage</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>30%</td>
        </tr>
        <tr>
            <td>2</td>
            <td>70%</td>
        </tr>
    </tbody>
 </table>

I would like to add a button with an event to every <td> element with a code, like the following:
Code:
<table>
    <thead>
        <tr>
            <th>Code</th>
            <th>Percentage</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><button onclick="reset(1)">Reset</button>1</td>
            <td>30%</td>
        </tr>
        <tr>
            <td><button onclick="reset(2)"></button>2</td>
            <td>70%</td>
        </tr>
    </tbody>
 </table>

Note that I'm not asking how to parse the HTML. Instead, I would like to know how to replace every \t\t\t<td>x</td> line by \t\t\t<td><button onclick="reset(x)">x</button></td>, where x is the code number.

I need to do it with a command-line text editor without input from the user, because I have many files like this one and my idea is to edit all of them using find with the -exec option.

This would be a simple task with ex or ed if I just had to replace the same concurrence. But in this case, I need to keep the code in every replacement. That's what I'm struggling with. I'm afraid I'll need advanced tools like awk and I honestly don't know how to do it.

How can I add the button with the event to the table cells?
Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Edit number of lines in a file to single line

Greetings, I have a file: hostnames.txt which has - # cat hostnames.txt machine1 machine2 I need the output to be saved to a variable as: HOSTNAMELIST=machine1,machine2 Please advise. Thanks, Chiru (3 Replies)
Discussion started by: chiru_h
3 Replies

2. Shell Programming and Scripting

Using cp: preserving file/folder attributes and auto creating folders

Hi, Is there a way to use cp in such a way that when a file is copied to a destination, the required destination folders are automatically created with the proper permissions, and the resulting copied file has the same attributes as the original. For example if I copied... (1 Reply)
Discussion started by: pcwiz
1 Replies

3. Shell Programming and Scripting

To Read a File and Insert a part of the lines into the database

Hi Guys I need to have a shell script which reads a log file and insert a part of each line into the database. Some sample lines in the file are as below. 20091112091359 MED_RQACK : user_data=60173054304,100232120,20091112091359,;ask_status=0;ask_reason=OK;msg_id=20091112091319... (5 Replies)
Discussion started by: Somanadh
5 Replies

4. Shell Programming and Scripting

How to edit file sections that cross multiple lines?

Hello, I'm wondering where I could go to learn how to edit file sections that cross multiple lines. I'm wanting to write scripts that will add Gnome menu entries for all users on a system for scripts I write, etc. I can search an replace simple examples with sed, but this seems more complex. ... (8 Replies)
Discussion started by: Narnie
8 Replies

5. Shell Programming and Scripting

Help in preserving special characters from input file

Hi Forum. I've tried to search online for a solution but I cannot seem to find one. Hopefully, someone here can help me out. I would appreciate it. Input file abc.txt: $InputFile_Borrower=CMTSLST\EDW_COMMERCIAL_MTGE_BORROWER_dat.lst... (14 Replies)
Discussion started by: pchang
14 Replies

6. Shell Programming and Scripting

Preserving Empty Lines while Replacing Numbers

Greetings, I am using tcsh to write a script that will replace the numbers in a file with a single number, the caveat is that this file has blank lines which are necessary for another step down the line so I need to preserve the blank lines. I have tried sed and awk but both will collapse the... (1 Reply)
Discussion started by: bonesy
1 Replies

7. Shell Programming and Scripting

Script to Check & Edit Content of a file (Addition of comma in each lines of code)

Hi all, I need to write an automated bash shell script which performs such operations: 1. Grep the header of everyline with the initial of "T" in "FILE_A" 2. Perform a for loop, Count the numbers of comma in the line of code, if (no. of comma < 17) ADD the comma until 17; ... (2 Replies)
Discussion started by: big_nutz
2 Replies

8. Shell Programming and Scripting

How to get awk to edit in place and join all lines in text file

Hi, I lack the utter fundamentals on how to craft an awk script. I have hundreds of text files that were mangled by .doc format so all the lines are broken up so I need to join all of the lines of text into a single line. Normally I use vim command "ggVGJ" to join all lines but with so many... (3 Replies)
Discussion started by: n00ti
3 Replies

9. Shell Programming and Scripting

Preserving file format and spacing in output file

Hi I have a file with the following structure "VATTENFALL GLOBAL" "Vattenfall Tray" "BARCLAYS BANK LONDON" "Capula" "P1 AGEAS GLOBAL COMPANY" "AAC - Optiver" The requirement is like this 1) Take 2 input... (16 Replies)
Discussion started by: sudeep.id
16 Replies

10. Shell Programming and Scripting

[Solved] Printing a part of the last line of the specific part of a file

Hi, I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this: Name =A xxxxxx yyyyyy zzzzzz aaaaaa bbbbbb Value = 57 This is necessary because in a file there are written more lines which... (6 Replies)
Discussion started by: wenclu
6 Replies
CW(7)							 Miscellaneous Information Manual						     CW(7)

NAME
CW - the international Morse code DESCRIPTION
CW is an abbreviation for "continuous wave", the commonly used technical term for Morse code communication. A basic knowledge or under- standing of Morse code is a requirement for Radio Amateurs and Marine Radio Operators in many parts of the world. MORSE CODE TIMINGS In Morse code, a dot or dash is referred to as an element. The basic timing unit is the dot period. This is the time taken to send a dot, not including any space before or after the dot. The lengths of all other elements are then derived from this basic unit, using the fol- lowing rules: The duration of a dash is three dots. The time between each element (dot or dash) is one dot length. The space between characters is three dot lengths. The space between words is seven dot lengths. The following formula calculates the dot period in microseconds from the Morse code speed in words per minute: dot period = ( 1200000 / speed ) This formula arises from the use of the word PARIS as a 'standard' word for calibrating Morse code speed. PARIS is 50 units long when sent in Morse code. Analysis of English plain-text indicates that the average word is 50 units, including spaces. MORSE CODE CHARACTERS The following list shows the IS0 8859-1 (Latin-1) characters that have commonly understood representations in Morse code: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"$()+-./:;=?_@ and space In addition, following ISO 8859-1 and ISO 8859-2 accented characters are also part of the generally accepted international Morse code: UACOEEANS (S with cedilla), (Z with caron/hacek), Finally, libcw adds the following ASCII characters as extensions to single character procedural signals: <>!&^~ MORSE CODE CHARACTER TABLES The following table shows the Morse code equivalents for the ISO 8859-1, accented ISO 8859-1, and accented ISO 8859-2 characters above. The ASCII portion of this table is taken from the ARRL Handbook, and the accented extensions from various other sources: Ch Code Ch Code Ch Code Ch Code ------------------------------------------------------- A .- B -... C -.-. D -.. E . F ..-. G --. H .... I .. J .--- K -.- L .-.. M -- N -. O --- P .--. Q --.- R .-. S ... T - U ..- V ...- W .-- X -..- Y -.-- Z --.. 0 ----- 1 .---- 2 ..--- 3 ...-- 4 ....- 5 ..... 6 -.... 7 --... 8 ---.. 9 ----. " .-..-. ' .----. $ ...-..- ( -.--. ) -.--.- + .-.-. , --..-- - -....- . .-.-.- / -..-. : ---... ; -.-.-. = -...- ? ..--.. _ ..--.- Ch Code Ch Code ------------------------------------------------- U ..-- A .-.- C -.-.. O ---. E ..-.. A .-..- A .--.- N --.-- S (S+cedilla) ---- (Z+caron/hacek) --..- In addition to the above standard characters, the following characters are conventionally used for punctuation and procedural signals as follows: Ch Code Ch Code Ch Code Ch Code ------------------------------------------------------- " .-..-. ' .----. $ ...-..- ( -.--. ) -.--.- + .-.-. , --..-- - -....- . .-.-.- / -..-. : ---... ; -.-.-. = -...- ? ..--.. _ ..--.- @ .--.-. and the following are non-conventional extensions implemented by libcw: Ch Code Ch Code Ch Code Ch Code ----------------------------------------------------- < ...-.- > -...-.- ! ...-. & .-... ^ -.-.- ~ .-.-.. An alternative view of punctuation and procedural signals is as combination Morse characters: Ch Prosig Ch Prosig Ch Prosig Ch Prosig --------------------------------------------------------- " [AF] ' [WG] $ [SX] ( [KN] ) [KK] + [AR] , [MIM] - [DU] . [AAA] / [DN] : [OS] ; [KR] = [BT] ? [IMI] _ [IQ] @ [AC] < [VA],[SK] > [BK] ! [SN] & [AS] ^ [KA] ~ [AL] NOTES
Despite the fact that this manual page constantly and consistently refers to Morse code elements as dots and dashes, DO NOT think in these terms when trying to learn Morse code. Always think of them as 'dit's and 'dah's. SEE ALSO
Man pages for libcw(3,LOCAL), cw(1,LOCAL), cwgen(1,LOCAL), cwcp(1,LOCAL), and xcwcp(1,LOCAL). CW Tutor Package CW(7)
All times are GMT -4. The time now is 08:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy