LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-28-2007, 08:29 PM   #1
craigjward
LQ Newbie
 
Registered: Nov 2007
Posts: 24

Rep: Reputation: 15
Scripting Current Working DIrectory


Hello,

I am doing a scripting assignment, and I have everything done except for setting my INFODIR variable to the current working directory. How do I go abouts doing this?

I have attached my code for reference.

Code:
#!/bin/bash

INFODIR=./

if [ $# -gt 1 ]; then 
	echo “Usage: fileinfo [directory path]”
	exit 1
elif [ $# -lt 1 ]; then
	INFODIR=$1
fi

echo "Processing $INFODIR"

for i in $INFODIR/*; do

	set -- $(ls -l $INFODIR/$i)
	

	 
		echo "|"
		echo "|+ Name : $8"
		echo "| L Owner : $3"
		echo "| L Permissions : $1"
		echo "| L Size : $5"


		YN="X"
			while [ $YN != "y" -a $YN != "n" ]
			do		
				echo "| > [?] Would you like to delete $8 (y/n)? "
				read YN
			
				if [[ $YN = y ]]; then
					rm $INFODIR/$1
				fi			
			done

done
 
Old 11-28-2007, 08:50 PM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
You would do:

Code:
INFODIR=`pwd`
 
Old 11-28-2007, 09:03 PM   #3
craigjward
LQ Newbie
 
Registered: Nov 2007
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by MS3FGX View Post
You would do:

Code:
INFODIR=`pwd`
I tried this. Both with and without ``

any other methods you can suggest?

thanks again for the help
 
Old 11-28-2007, 10:37 PM   #4
FragInHell
Member
 
Registered: Sep 2003
Location: Sydney Australia
Distribution: Redhat, Centos, Solaris, Ubuntu, SUSE
Posts: 282

Rep: Reputation: 45
make sure you use ` and not '.

The ` tells the system its a system call or command rather than ' which assigns a value.
 
Old 11-29-2007, 03:46 PM   #5
craigjward
LQ Newbie
 
Registered: Nov 2007
Posts: 24

Original Poster
Rep: Reputation: 15
never mind.. I figured it out. Thanks!

Last edited by craigjward; 11-29-2007 at 04:12 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change current working directory in C++? g4j31a5 Programming 4 05-09-2007 11:18 PM
About current working directory George2 Programming 5 05-02-2007 10:47 PM
how do I find out the current working directory? nodger Programming 2 12-26-2004 12:28 PM
current working directory in ksh prompt brian0918 Linux - Newbie 2 06-03-2003 05:34 PM
current working directory in ksh prompt brian0918 Linux - Software 2 06-03-2003 02:50 PM


All times are GMT -5. The time now is 05:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration