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,...
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.
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...
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....
Write UNIX commands to perform the following tasks. Each task must use exactly one line of...
Write UNIX commands to perform the following tasks. Each task must use exactly one line of command. Unless stated otherwise, all files are assumed to be at your current working directory. a) (10 points) Print your current working directory into a file named file1 b) (10 points) Assume that your current working directory is NOT the same as your home directory. Print all file and subdirectory names of your home directory into a file named file2. c) (15 points) Copy...
Following are the most important file management functions available in C. Use any 6 of them...
Following are the most important file management functions available in C. Use any 6 of them in your program and show the output. Function purpose fopen () Creating a file or opening an existing file fclose () Closing a file fprintf () Writing a block of data to a file fscanf () Reading a block data from a file getc () Reads a single character from a file putc () Writes a single character to a file getw () Reads...
Write a python code to print (any given file) file as a csv format by using...
Write a python code to print (any given file) file as a csv format by using MRJob only. code must be able to run stand-alone MRJob application. For submission to your work: Your final hand should be a single file name BDM.py that takes exactly one arguments for the input path. output will be handled through redirection. Sample run: python BDM.py sample.csv > output.csv
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT