0

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

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by eggi
0

Save the file with a .sh extension, then add executable permissions:

$ chmod ugo+x shell-script.sh

Now run it:

$ ./shell-script.sh

Note that your current directory doesn't have to be where the script is to run it:

$ /some/path/shell-script.sh
0

I am a little confused as what program you need to run this code?

0

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/*

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.