Need help writing a shell script program

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Need help writing a shell script program
# 1  
Old 04-02-2013
Need help writing a shell script program

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
Write the a shell script program to remove all space characters stored in the shell variable TEXT. TEXT='onespace ,twospaces ,threespaces ,fourspaces ,'. Be sure to assign the results back to TEXT. Display the value of the TEXT variable to standard out. Do this using the tr command.


2. Relevant commands, code, scripts, algorithms:
tr


3. The attempts at a solution (include all code and scripts):
How do i go about writing a shell script program? If you can help me with that im hoping I can figure out how to answer the question.


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Calvin College, Grand Rapids MI, USA, Johnson, CO142.

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 04-02-2013
To delete spaces from a file:
Code:
tr -d ' ' < inputfile > outputfile

To do this to a string in the shell you must use echo and pipes.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 04-02-2013
A shell program is simply a collection of commands. And when the commands are put together, the desired result is achieved.

The #1 tells you the variable TEXT and the command to be used tr.
What have you tried, what examples of work can you share?
This User Gave Thanks to joeyg For This Post:
# 4  
Old 04-02-2013
Quote:
Originally Posted by Corona688
To delete spaces from a file:
Code:
tr -d ' ' < inputfile > outputfile

To do this to a string in the shell you must use echo and pipes.
Thanks so much for the reply. I guess im still quite confused by the question. Am I creating a file with vi called "TEXT" with the content of "onespace, ect.."?

Props to you Linux guys who understand this stuff. I feel so lost in this class. Thanks for the help.
# 5  
Old 04-02-2013
That is one way to create a file

Also, you could
Code:
$ echo one two three >sample2.txt

$ cat sample2.txt
one two three

However, what you wrote did not say a file but a variable!
This User Gave Thanks to joeyg For This Post:
# 6  
Old 04-02-2013
Quote:
Originally Posted by joeyg
Also, you could
Code:
$ echo one two three >sample2.txt

$ cat sample2.txt
one two three

However, what you wrote did not say a file but a variable!
i figured I wasnt putting it into a file.
# 7  
Old 04-02-2013
Quote:
Originally Posted by kofine05
Thanks so much for the reply. I guess im still quite confused by the question. Am I creating a file with vi called "TEXT" with the content of "onespace, ect.."?
You do not need to create a file necessarily. Did they tell you anything about backticks and pipes?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need help in writing shell script

Dear Team, Below is the list of steps i need to perform manually as of now and completely new to shell scripting, could you help in writing a shell script to perform the below procedure? 1. Log in to primary DNS server 2. Check /etc/named.conf if zone is already created (grep –i... (2 Replies)
Discussion started by: VKIRUPHAKARAN
2 Replies

2. UNIX for Dummies Questions & Answers

Need help writing shell script!

Hi, I'm very new to this, so bear with me please. I want to write a sh script (or if there's a better format please let me know) that allows me to, when I run it, print the date to a file (1.out) take 2 arguments (files a.fa and b.fa), run them with another program, outputting to 2.out, and then... (4 Replies)
Discussion started by: ShiGua
4 Replies

3. Programming

writing a shell program in ubuntu

Hi all, I have an assignment from school to write a shell program in linux. the idea is to exercise fork() and execv() functions.. the shell program is supposed to be the master and every command that the user prints will run in a new process. we also need to try running the command in every... (1 Reply)
Discussion started by: r3vive
1 Replies

4. Shell Programming and Scripting

Writing a shell script

Hi I have two files a.log and b.log . i need to append a.log and b.log so that at the end of first line in a.log i need the append the data of first line from b.log and end of the second line in a.log i need to append the data of second line from b.log and so on up to the end of the file can... (3 Replies)
Discussion started by: lalu
3 Replies

5. Shell Programming and Scripting

Need help in writing the shell script

Can anyone please help me in writing a shell script that would check if a particular user(xyz) has logged in, and if yes, the audit daemon needs to be started. When the user logs off the dameon needs to shutdown , and the report needs to be e-mailed to a set of users. (12 Replies)
Discussion started by: ggayathri
12 Replies

6. Shell Programming and Scripting

Having trouble writing a basic shell program

Hello. I'm trying to write a shell script that will take files that have .tar, .tar.gz, .tar.Z, .gz, .Z and .zip file extensions and uncompress and unarchive them. The script should be able to take multiple arguments. So far I can write a script using the case command that will do this but it will... (3 Replies)
Discussion started by: SeanWuzHere
3 Replies

7. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

8. Shell Programming and Scripting

Need help for writing shell script

Hello ALL, I am fresher in Unix . i need help to write small shell script . Please help me unix guru. I am developing the internal site in my office . the data files are generated in one directory everyday . I have to write shell script to sort those files and put it is internal site . ... (3 Replies)
Discussion started by: deepa20
3 Replies

9. UNIX for Dummies Questions & Answers

Writing a shell Script

How to write a shell script file to read 5 numbers using a while loop. Finding the average, maximum and minumum for the numbers. Any help would be great. (1 Reply)
Discussion started by: Chin
1 Replies

10. Shell Programming and Scripting

Need help with writing shell script

I have the following output. I want to write a script to check for 1. waits > 0 on all rowsand Ratio > .0. if true then send email. ========================= ROLLBACK SEGMENT CONTENTION ========================= If any ratio is > .01 then more rollback segments are needed NAME ... (1 Reply)
Discussion started by: jigarlakhani
1 Replies
Login or Register to Ask a Question