LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 08-18-2009, 11:51 PM   #16
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137

Whatever ways from mentioned here you choose it's important to verify,
that VAR you get is not empty
Code:
VAR=
cd $VAR
Will change dir to your home directory, and it's not probably what you want.
Espesially, if this 'cd' followed by some kind of 'rm -rf'
 
Old 08-18-2009, 11:54 PM   #17
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Quote:
Originally Posted by Valery Reznic View Post
Whatever ways from mentioned here you choose it's important to verify,
that VAR you get is not empty
Code:
VAR=
cd $VAR
Will change dir to your home directory, and it's not probably what you want.
Espesially, if this 'cd' followed by some kind of 'rm -rf'
Indeed! That is a MOST excellent point you make, and it should have been made much earlier in the thread

Thanks Valery,

Sasha
 
Old 08-19-2009, 12:01 AM   #18
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by GrapefruiTgirl View Post
Indeed! That is a MOST excellent point you make, and it should have been made much earlier in the thread :)

Thanks Valery,

Sasha
Hehe. Some loooooong time ago, I myself wrote script where variable name in the cd arg was misspelled... and end up without my home directory. :(

So from that time I learn (by hard way !) that cd is easily one of the most dangerous Unix command :)
 
Old 08-19-2009, 12:07 AM   #19
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
I suspect many of us have done similar careless/stupid things -- I know I have at least once!

Isn't it amazing how blazingly fast an errant "rm -Rf" will wipe the root filesystem!?!? I did this once, thinking I was chrooted, but I wasn't.. Luckily I had a very recent backup!

Sasha
 
Old 08-19-2009, 10:20 AM   #20
ECRocker
Member
 
Registered: May 2007
Distribution: RHEL 5, Ubuntu 9.10, Fedora 12
Posts: 85

Original Poster
Rep: Reputation: 17
Quote:
Heh ... could be done w/o xargs, too.
Code:
 cd $( dirname $( locate $1 |head -n 1 ))
Actually prettier, I feel ;}
I agree, cleaner.

I've got a lot of work a head of me to figure out how that works, but it really does work (if you've got a very specific file name) which you type after the locate command.

Rad to the Max!
I can add Tink mentioned before in ~/.bashrc but I hope this gets added to bash permanently one day.
 
  


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
square brackets in output of "ps aux" not matching output of "ps -ejH" alirezan1 Linux - Newbie 14 07-14-2010 04:17 AM
Courious "unknown" entries in "netstat" output Sheridan Linux - Networking 5 09-01-2009 09:09 AM
"failed to execute child process" "Input/output error" fl.bratu Fedora 4 12-15-2008 04:03 AM
SFTP - CyberDuck doesn't work, but WinSCP does? Server exited on signal "PIPE"? dragos19 Other *NIX 1 10-04-2008 04:52 PM
Feeding the output of "diff" or "cat" command to dpkg --purge kushalkoolwal Debian 9 06-19-2008 07:27 AM

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

All times are GMT -5. The time now is 07:07 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