Sh, Bourne Problem with getting lines in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sh, Bourne Problem with getting lines in a file
# 1  
Old 05-08-2008
Sh, Bourne Problem with getting lines in a file

This is a new exercise for me
1.) Create a bourne shell script that can accept 2 arguments/parameters. Name your script as housekeep_files.sh.

2.) The script will delete the files specified in the input file (1st parameter) and will send a notification through email (2nd parameter) the list of files deleted.

Sample input file: /home/mis/training/tanzs/files_to_delete.txt
ex. files_to_delete.txt
man.txt
see.txt
go.txt
no.txt

Being relatively new to this type of programming, I don't know how to approach this. How can I get the man.txt and seperate it from see.txt?
Is there any way to loop this and put it in an array while it is not end of file? Also does bourne support array? so i can put these text into an array? file[i]=??
# 2  
Old 05-09-2008
This is your script file:
Code:
for i in `cat $1`
do
 rm $i
done

And you run it:
Code:
</> housekeep_files.sh files_to_delete.txt

But not know exactly what you you want with second param...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

bourne script problem

I've got an NTFS file system mounted on my Linux box, which means I can have multi-word directory names. I want to recurse through the directory structure copying stuff from /A to /B when it does not already exist on /B. Here is the chunk of code, and the output of a set -x run on that chunk of... (8 Replies)
Discussion started by: esmith92000
8 Replies

2. Shell Programming and Scripting

odd problem in read lines from file

Hi, I wrote a small program to read lines from a file and count the lines. The program is as below: filename=$1 count=0 cat $filename | while read -r line do printf "%5d:%s\n" $count "$line" count=$((count + 1)) done echo " $count " After I run the program, the result is... (4 Replies)
Discussion started by: jianma
4 Replies

3. Shell Programming and Scripting

Bourne Shell - Problem with while loop variable scope.

Hello I am having issues with a script I'm working on developing on a Solaris machine. The script is intended to find out how many times a particular user (by given userid) has logged into the local system for more than one hour today. Here is my while loop: last $user | grep -v 'sshd'... (7 Replies)
Discussion started by: DaveRich
7 Replies

4. Shell Programming and Scripting

Problem in deleting lines from the file

Hi All I am not able to delete few line from long file. I have a big file which is of 53998 B in size i want to delete lines starting from 32768 to 53998 and collect remaining file in new file. It is giving exception sed: command garbled: 32768,$countd Please find the sample script... (2 Replies)
Discussion started by: rajeshorpu
2 Replies

5. Shell Programming and Scripting

Problem with Script that writes max lines of a file - Any ideas how to fix?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (4 Replies)
Discussion started by: mmiller99
4 Replies

6. Shell Programming and Scripting

if loop problem in bourne shell

how to use if-loop in bourne shell with multiple conditions like follows if then commands fi it gives me an error test: ] missing then i put if ] it gives me an error [[ not found kindly i need the syntex for the bourne shell (5 Replies)
Discussion started by: ahmad.diab
5 Replies

7. Shell Programming and Scripting

please give a bourne script to this problem

Hello all, I am new to unix and having the below problem.Any help will be appreciated. Write a Bourn shell script dTOe which takes as an input any number between 0 and 999 and prints the English value for this number. The program should display an error message when a NOT digit value entered.... (1 Reply)
Discussion started by: raj1811
1 Replies

8. UNIX for Dummies Questions & Answers

If file exists (bourne shell)

Im trying to code some logic into a test script to test for the existence of a file before recreating it. Im using the following line to test for this: if -r test.txt; However I get the error message ./testScript.sh: -r: not found Having read through the man pages im still not clear whats... (2 Replies)
Discussion started by: blakmk
2 Replies

9. Shell Programming and Scripting

simple Bourne problem

Hi, I'm a newer for this languages, and I have a log file, which is something like this: 35.75.253.207 - - "GET /products/orgonizer/title.png HTTP/1.1" 200 1555 "-" "Mozilla 1.4" Now, I want to write a shell code to accoplish like ./XXX.sh -N n n is a number by user input, the code should... (5 Replies)
Discussion started by: pnxi
5 Replies

10. Shell Programming and Scripting

bourne mail script problem

Hey there, Just have a quick question. i've written a program and it needs to send a email to confirm it's completed. now i've done the mail -s "Subject" test@test.com the problem is the program, when run just waits. it doesn't execute the next command unless i press ^D. is there away... (6 Replies)
Discussion started by: Priest_Ridden
6 Replies
Login or Register to Ask a Question