LinuxQuestions.org
Review your favorite Linux distribution.
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, 07: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, 07:50 PM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
You would do:

Code:
INFODIR=`pwd`
 
Old 11-28-2007, 08: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, 09: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, 02: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 03: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 10:18 PM
About current working directory George2 Programming 5 05-02-2007 09:47 PM
how do I find out the current working directory? nodger Programming 2 12-26-2004 11:28 AM
current working directory in ksh prompt brian0918 Linux - Newbie 2 06-03-2003 04:34 PM
current working directory in ksh prompt brian0918 Linux - Software 2 06-03-2003 01:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:30 PM.

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
Open Source Consulting | Domain Registration