LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-26-2008, 05:14 PM   #1
uid0sd
Member
 
Registered: Aug 2006
Distribution: Mac OS X, Debian, Ubuntu
Posts: 37

Rep: Reputation: 15
BASH "exit"s


Hi.

I have a BASH script that starts off by changing directories;


cd /path/to/files

find . -type f -mtime +7 -exec rm {} \;


Must I use `cd` or `exit` at the end or is it good like this?

Last edited by uid0sd; 03-26-2008 at 05:17 PM.
 
Old 03-26-2008, 05:23 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
When the script ends the current working directory will go back to what it was before you called the script. Is that the question you were asking?

-------------------
Steve Stites
 
Old 03-26-2008, 05:26 PM   #3
uid0sd
Member
 
Registered: Aug 2006
Distribution: Mac OS X, Debian, Ubuntu
Posts: 37

Original Poster
Rep: Reputation: 15
Pretty much, I didn't know weather to exit or cd back. Thanks for the info!
 
Old 03-26-2008, 05:26 PM   #4
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
What is wrong with:

Code:
find /path/to/files -type f -mtime +7 -exec echo {} \;
All the "." does in the find command is say, "use the current directory". If you want to use a different directory, specify one.

(change echo to rm above when you are satisfied it works).

HTH

Forrest
 
Old 03-26-2008, 05:33 PM   #5
uid0sd
Member
 
Registered: Aug 2006
Distribution: Mac OS X, Debian, Ubuntu
Posts: 37

Original Poster
Rep: Reputation: 15
Good point!
 
  


Reply



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
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
tar "Error exit delayed from previous errors" using "-C /" ToK Linux - Software 2 03-19-2008 06:49 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
Assembly, "bash: ./exit: cannot execute binary file" User Name. Programming 4 08-07-2007 09:09 AM
bash-2.05b# Xlib: extension "XFree86-DRI" missing on display ":0.0". citrus Linux - General 8 02-22-2004 10:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:43 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
Open Source Consulting | Domain Registration