Bash programming help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash programming help
# 1  
Old 05-08-2011
Bash programming help

Hello all;

I have little knowledge of bash programming, and I was wondering if you could help me out.

I would like to create a bash script, as detailed below.

process.sh is the bash script itself
list.dl is a text file. In this text file, the first line is the directory from /var/www/downloads/ I would like it to be (so if the first line is "testing" the full directory would be /var/www/downloads/testing). Starting from the second line downward, there are direct URL download links.

This is what I want the script to do:
1. Read the first line of the textfile list.dl and save it as a variable.
2. Delete the first line so that every used line becomes a URL download link
3. Add the variable to the directory path (/var/www/downloads/testing if the first line said "testing")
4. Go to the directory path (/var/www/downloads/testing)
5. Wget every link from the text file to there
6. Output a text file with all links to the files on the server (/var/www/downloads/testing/test.zip is already <ip>/download/testing.zip on my server) so that I may download them.

I have absolutely no idea how to program this, any help would be appreciated.
Sincerely,
tehalexf
# 2  
Old 05-08-2011
This does not delete the first line of input. It works non-destructively
Code:
cnt=0
mydir=/var/www/downloads
while read rec
do
   cnt=$((  $cnt + 1 ))
   if [ $cnt -eq 1] ; then
         cd $mydir/${rec}
         continue        
   fi
   wget [you put options here if you want them] $rec
done < test.dl

common options are:
-nc do not overwrite existing files
-O filename one single filename for all of the downloads from one URL
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Bash Programming. Could anyone help me?

Hi! I'm new in bash programming and I need to make an script that reads a txt file line by line (every line is like "Name;FirstLastName;SecondLastName;Sex") and has to give every student 3 random marks, its average and add a counter if they are male/female and if they passed. I've been trying with... (4 Replies)
Discussion started by: HeartHacker
4 Replies

2. Shell Programming and Scripting

Chunks of bash shell programming

I am going to provide a chunks of codes that I do not understand. Please help with them in a layman's terms. 1) ${DEBUG:-0} -------------------------------------------------------------------------- 2) print "${1}" ... (7 Replies)
Discussion started by: lg123
7 Replies

3. Shell Programming and Scripting

ctrl-c in bash script - Programming

Hi All, I need to place a ctrl-c interrupt in a bash script, there is no other way, it has to be done :) can someone please advise how would I go about this? i want to use ctrl c in below code, after the code excution of just 1 min or 1sec java Cspsamp 111.19.5.172 7025 rd1... (6 Replies)
Discussion started by: aish11
6 Replies

4. Homework & Coursework Questions

Bash Shell Programming assignment.

Please take a look I am stuck on step 4 1. The problem statement, all variables and given/known data: #!/bin/bash ### ULI101 - ASSIGNMENT #2 (PART A) - DUE DATE Wed, Aug 3, 2011, before 12 midnight. ###==================================================================================== ###... (13 Replies)
Discussion started by: almirzaee
13 Replies

5. Shell Programming and Scripting

Example in Pro Bash Programming book problem

I am going through the examples in the book "Pro Bash Programing" which is quite a good book on bash programing. Just a word of warning about the example script called sa that simply shows command line arguments. In CentOS 5.5 there is a program called sa already on the system. Boy did that throw... (0 Replies)
Discussion started by: simusphere
0 Replies

6. Shell Programming and Scripting

Bash time and programming

I have inherited a C++ program which does not manage it's memory at all. It has a whole bunch of 'new' variables without many deletes. I believe it was the programmers intent to let the OS clean up. Correct me if I am wrong, but I believe the unix/linux systems clean up after the program... (1 Reply)
Discussion started by: JDKunk
1 Replies

7. Shell Programming and Scripting

bash programming

how do you allow a user to input a particular group name as an argument?? thnx for your time. (2 Replies)
Discussion started by: bumdeal2
2 Replies

8. Shell Programming and Scripting

Bash Programming

Write a Shell script to analyse the disk usage of students in a particular class. The program should allow the user running the script to input the particular class name (group name) as an argument to the script. The script should create a file called “logfile” in the home directory of the user... (2 Replies)
Discussion started by: bumdeal2
2 Replies

9. Shell Programming and Scripting

help bash programming

how to i grep a keyword which ignore upper case or lower case. for an example : user enter CoUcH and the grep also can grep couch which in text.txt although upper or loever case is different .. how to do that ? any idea? (1 Reply)
Discussion started by: CheeSen
1 Replies

10. Shell Programming and Scripting

Programming in ksh and not in bash

Hi all.... I was wondering if there is a lot of differences between /bash and ksh programming. Im learning about bash programming, but all what I had read in this forum, points me to learn more about ksh over bash. Is that right and why? Unfortunately, I can’t write ksh progs on my work,... (2 Replies)
Discussion started by: TARFU
2 Replies
Login or Register to Ask a Question