How does this look

Reply

Join Date: Jul 2008
Posts: 21
Reputation: army88m2 is an unknown quantity at this point 
Solved Threads: 0
army88m2 army88m2 is offline Offline
Newbie Poster

How does this look

 
0
  #1
Aug 3rd, 2008
I was wondering how this looks. I am trying to create a script that will produce a text file that has a list of the files in the present working directory. How do you go about testing this script?

#!/bin/bash
#
# Matthew Smith# Comp230
ls >FILE.txt
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: How does this look

 
1
  #2
Aug 3rd, 2008
Save the file with a .sh extension, then add executable permissions:
Shell Scripting Syntax (Toggle Plain Text)
  1. $ chmod ugo+x shell-script.sh
Now run it:
Shell Scripting Syntax (Toggle Plain Text)
  1. $ ./shell-script.sh

Note that your current directory doesn't have to be where the script is to run it:
Shell Scripting Syntax (Toggle Plain Text)
  1. $ /some/path/shell-script.sh
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 21
Reputation: army88m2 is an unknown quantity at this point 
Solved Threads: 0
army88m2 army88m2 is offline Offline
Newbie Poster

Re: How does this look

 
0
  #3
Aug 3rd, 2008
I am a little confused as what program you need to run this code?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 21
Reputation: army88m2 is an unknown quantity at this point 
Solved Threads: 0
army88m2 army88m2 is offline Offline
Newbie Poster

Re: How does this look

 
0
  #4
Aug 3rd, 2008
Also I need some help here with this code. I need to create a bash script that will copy all the files and subdirectories in one directory to a newly created directory. Here's what I came up with.

cp -R dir/*newdir/*
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: How does this look

 
0
  #5
Aug 5th, 2008
You pretty much have your entire script right there, assuming you don't need to be any more creative, just add a

#!/bin/bash

line to the top and make it executable, etc, per the above post by John A

Best wishes,

Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC