Shell Script Table


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script Table
# 1  
Old 12-10-2013
Shell Script Table

Hi,

i need a bit help. I must write a script with shell- and sed-commands, which reads a table from stdin and writes a html-table on stdout (so i can open it with a web browser). The number of columns must be a parameter for the script, so i can start it for example with: "./htmltab.sh 3 <table-data". (sry if my english is bad)
# 2  
Old 12-10-2013
What have you tried?
# 3  
Old 12-10-2013
Not much. I'm searching and reading the whole day but I don't know how to begin. It's difficult to me to understand the whole linux system with STDIN and STDOUT. I'm new with linux. I'm studying and the lessons and tasks we get in Scripting are not very well organised. We must write a script which reads a table like this:

Name \t Size \t Type
bla \t 4711 \t f i l e
abcde \t 4096 \t directory

and then writes a html-table. We got the structure for the html-table because we never worked with html, but it doesn't helps me a lot...it would be easier to explain the task in german...I know for example how to find and extract words from a text with 'sed' but not how I should read a table and convert it.
# 4  
Old 12-10-2013
Standard input and output amount to pre-opened files. Usually, standard input is connected to your keyboard, and standard output is connected to your screen, but the shell lets you attach them to anything you want like this:

Code:
./myscript < inputfile > outputfile

< redirects standard input. Any commands you run in that script, and the read builtin, will read from inputfile instead of the keyboard.

> redirects standard output. Any commands you run, and the echo builtin, will write to outputfile instead of the terminal.

So when they are telling you to read from standard input, they are telling you to just read from the default with read and feed whatever you want into it later.

You use read like
Code:
read VAR1 VAR2 VAR3 VAR4

and if the first line is A B C D E, it effectively does VAR1="A"; VAR2="B" ; VAR3="C" ; VAR4="D E"

And 'standard output' just means 'print to the terminal with echo or whatever'.

We really can't give you a direct answer, we can give you the tools. And this should really be in the homework forum, please re-post there following the homework template.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Download a db table through UNIX shell script

Hi, I'm an amateur and need your help in figuring this out. I have been asked to connect to a prod db from non-prod env., and download a table from prod db to non-prod env. I was able to connect to the prod db and then run a simple query as below. @@@@@@@@@@ ... (7 Replies)
Discussion started by: arunpvp
7 Replies

2. Homework & Coursework Questions

Help with pivoting table shell script

input file txt file 2000 1 name 2000 2 addr 2000 3 phone 2000 4 email 1000 1 name 1000 2 addr 1000 3 phone 1000 4 email 3000 1 name 3000 2 addr 3000 ... (4 Replies)
Discussion started by: senmatrix
4 Replies

3. Shell Programming and Scripting

Shell script to query Oracle table

Hi, unix gurnis I need help for following requirement for writing a shell scritp. log in to oracle database, query one table total records (select count(*) from table1), pass the return value to a file. Thanks in advance (2 Replies)
Discussion started by: ken002
2 Replies

4. Shell Programming and Scripting

Create DB table through shell script

Hi, Can anyone tell me that, How to create table in Oracle database through shell script(ksh). Table contains 3 fields, 1] Emp ID, String, primary key 2] Name, String 3] B Date, date. Thanks in advance. (6 Replies)
Discussion started by: Poonamol
6 Replies

5. Shell Programming and Scripting

Truncating table from a shell script

I am trying to truncate a table using below script. When I ran the script it runs fine but table was not truncated and the spool is empty. I am not sure what is wrong with pl/sql block. #!/bin/ksh # ---------------------------------------------------------------------- # # Created by: XXXX... (2 Replies)
Discussion started by: gunaah
2 Replies

6. Shell Programming and Scripting

Is it possible to draw table/matrix using shell script?

Hi all, I need to create a matrix of variable rows and columns. Right now i have 3 rows and two columns and following values. Output something like TypeA TypeB TestCase1 Pass Fail TestCase2 Pass ... (2 Replies)
Discussion started by: jakSun8
2 Replies

7. Shell Programming and Scripting

How to connect DB2 table using shell script

Hi All, I want to connect two tables in DB2 using shell script and then compare the contents of two tables field by field. Could any one please help me in connecting database tables using Unix and retriving data from the same. Thanks, Durwas (0 Replies)
Discussion started by: dtidke
0 Replies

8. Shell Programming and Scripting

Alter Table Shell Script

I want to add some columns to a existing tables through a shell script. Please help. (2 Replies)
Discussion started by: ankitgupta
2 Replies

9. Shell Programming and Scripting

Reading a table in a shell script

Dear all: I want to write a script capable of reading specific rows and collumns of a table, into a variable. Just imagine i have a file named table.dat which contains: GENERAL INFORMATION Col 1 Col2 Col3 1 1 2 2 3 3 4 4 What i want to do... (13 Replies)
Discussion started by: luiscarvalheiro
13 Replies

10. UNIX for Advanced & Expert Users

Creating a hash table using shell script

Hi, For one of my programs, I need to have a hashtable as in Perl. Unfortunately shell doesnt provide any variable like hash. Is there anyway/trick, I could implement a hash in shell (using shell scripts/sed/awk). JP (2 Replies)
Discussion started by: jyotipg
2 Replies
Login or Register to Ask a Question