Question

Write an awk (nawk) or sed command file that converts a textfile to a html file...

Write an awk (nawk) or sed command file that converts a textfile to a html file (by inserting tags <HTML><BODY><PRE> at the beginning of your existing file: file1.txt and inserting tags </PRE> ></BODY></HTML> at the end of file1.txt)

Sample Run:

awk -f awkfile.txt file1.txt > file1.html

or use

sed –f sedfile.txt file1.txt > file1.html

Sample Output:

Use a browser to show your file1.html

Homework Answers

Answer #1

This script file can be used to convert a text file to html file

#! /bin/bash
 
if [ $# -eq 0 ] ; then
   echo "USAGE: $(basename $0) file1 file2 file3 ..."
   exit 1
fi
 
for file in $* ; do
   html=$(echo $file | sed 's/\.txt$/\.html/i')
 
   echo "<html>" > $html
   echo "   <body>" >> $html
   echo "   <pre>" >> $html
 
   while read line ; do
      echo "$line<br>" >> $html
   done < $file
 
   echo "   </body>" >> $html
   echo "</html>" >> $html
   echo "   </pre>" >> $html
done



This below command will simply convert any html file to text file without using script file

sed 's/<[^>]*>//g ; /^$/d' htmlpage.html > output.txt
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program in python that takes a txt file and converts it to html
Write a program in python that takes a txt file and converts it to html
UNIX COMMANDS Task B Create a one-line command, using the famous.dat file, to add the word...
UNIX COMMANDS Task B Create a one-line command, using the famous.dat file, to add the word " STREET" to the address, for all who live on 2nd or 3rd. For example: "2nd" becomes "2nd STREET" and "3rd" becomes "3rd STREET". Display only the first 9 lines. Hint: Use 2 sed statements with pipes. Task C Display all lines in famous.dat that end in 0 or 1, and have a 1 in the 3rd from the last column. For example lines...
5. Write a bash command that will display the name of every file on the Linux...
5. Write a bash command that will display the name of every file on the Linux system whose file contaent contains the string "doug.jones". The command must run in the background, must redirect standard error to /dev/null, and must redirect standard output to ~/out. 6. Write a bash command that will kill all of the even-numbered processes associated with your userid, and no other processes. 7. Write a bash command that will start the program /home/courses/140u-doug.jones/zombie_maker as a background process,...
For this assignment, you will write a timer application in HTML and JavaScript. Your HTML document...
For this assignment, you will write a timer application in HTML and JavaScript. Your HTML document should contain the following elements/features: 1. HTML tags: a. An <input> tag labeled "Timer Duration" with the initial value 0 b. A <button> tag labeled "Start" 2. Script: When the user presses the button (1b), a function will begin that does the following: a. Reads the value from the input field (1a) b. Removes the <input> and <button> tags (1a & 1b) c. Creates...
Write an M-File scripts that converts temperature in degrees Fahrenheit ( °F) to degrees Centigrade (...
Write an M-File scripts that converts temperature in degrees Fahrenheit ( °F) to degrees Centigrade ( °C) by recall the conversion function in (a). Use input and disp commands to display a mix of text and number.
Write a python program that prompts the user for a web address (full url, html page)...
Write a python program that prompts the user for a web address (full url, html page) and then uses the BeautifulSoup and urllib to read its data. You can use the any html page you'd like: The program should output the following: The page title (hint: read the content from the metatag "title") The total number of words on the page The total number of unique words on the page The total number of each heading used on the page...
Subject: Shell Scripting Practice A File: practice-script-a Create File practice-script-a that: 1. Accepts any number of...
Subject: Shell Scripting Practice A File: practice-script-a Create File practice-script-a that: 1. Accepts any number of userids on the command line 2. For each userid, display the userid, PID, CPU time, and current command for each process owned by that userid Your output should look similar to this example: practice-script-a doug.jones User: doug.jones PID: 8748 TIME: 00:00:00 COMMAND: /usr/lib/systemd/systemd --user User: doug.jones PID: 8749 TIME: 00:00:00 COMMAND: (sd-pam)    User: doug.jones PID: 8750 TIME: 00:00:00 COMMAND: sshd: doug.jones@pts/5 User: doug.jones...
Linux Operation SECTION 2 – File and Directory Permissions: FILE PERMISSIONS: What is the command used...
Linux Operation SECTION 2 – File and Directory Permissions: FILE PERMISSIONS: What is the command used to find out which user account you are logged into?      . This command may come in handy in the following exercises. Ensure you are in your home directory of the student1 account. Use the echo command with output redirection to create a file called labfile4 and put the following text in this file: “This is the first line of labfile4”. Using the symbolic notation...
Utilizing PHP and HTML For this lab we will save some cookie data to the computer,...
Utilizing PHP and HTML For this lab we will save some cookie data to the computer, and then in a new browser session, read the data. Attached is a zip file with a simple form with three fields on it, email address, favorite food and year you were born. Put in the code for the action script and the name attributes on the inputs. In the action script, save these values to cookies that will live for 15 minutes. This...
Write Linux command lines to do the following: 1. Create a directory with name “yourName_ID” 2....
Write Linux command lines to do the following: 1. Create a directory with name “yourName_ID” 2. Create a file with name “yourLastName.txt” inside the directory created in step.1 3. Write inside the created file exactly the following content (you may use editors such as vim, pico, ….): Linux Lab Lab. ToDo#1 Summer Semester 2019/2020# 4. Display the first 2 lines of the file. 5. Change the permission of the file to read write and execute for owner, groups and others....