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 08-19-2009, 12:51 AM   #16
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 675

Rep: Reputation: 136Reputation: 136

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-19-2009, 12:54 AM   #17
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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, 01:01 AM   #18
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 675

Rep: Reputation: 136Reputation: 136
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, 01:07 AM   #19
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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, 11: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


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


All times are GMT -5. The time now is 12:58 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration