theweaselking: (Work now)
[personal profile] theweaselking
Interview question:  "What command would you use to find a file in Linux?"
A: "Locate"
Q:"What if Locate isn't installed?"
A:"Find."
Q: "What if Find isn't installed?"
A:"Grep"
Q: "What if Grep isn't installed?"
A: "Apt-get".

(no subject)

Date: 2011-07-28 05:21 pm (UTC)
From: [identity profile] mhoye.livejournal.com
Oh, poor interviewer. Fishing for 'ls' and not knowing what the rest of it meant.

(no subject)

Date: 2011-07-28 05:32 pm (UTC)
From: [identity profile] theweaselking.livejournal.com
Grep not being installed is a very sad thing, for the record. But still funny.

(no subject)

Date: 2011-07-28 09:57 pm (UTC)
From: [identity profile] rbarclay.livejournal.com
Is that even possible on any current Linux distri?
$ apt-cache show grep
Package: grep
Essential: yes
Priority: required

(no subject)

Date: 2011-07-28 10:07 pm (UTC)
From: [identity profile] theweaselking.livejournal.com
I have no idea. It's a hypothetical!

(no subject)

Date: 2011-07-28 10:14 pm (UTC)
From: [identity profile] theweaselking.livejournal.com
Also: You could probably combine the above tools to get something like "sudo find / -n grep -x rm -rf {} \"

Which would make grep awfully hard to use!

(no subject)

Date: 2011-07-28 11:02 pm (UTC)
From: [identity profile] dglenn.livejournal.com
On further reflection, I don't think any of the situations where I lacked 'ls' had grep either. So it turns into using 'echo' with a clever selection of wildcards.

Am I showing my age?

(no subject)

Date: 2011-07-29 02:55 pm (UTC)
From: [identity profile] en-ki.livejournal.com
grep is before ls alphabetically, so you would generally lose it first in the traditional "runaway rm" situation.

Fortunately, /usr/bin/ruby is *way* later.

(no subject)

Date: 2011-07-29 03:17 pm (UTC)
From: [identity profile] dglenn.livejournal.com
Oh, it wasn't a runaway 'rm'. It was a "the boot medium is really too small for the tools" situation. (Not so common with (what's it called, busybox?) on compressed HD floppies like "tomsrtbt", and a lot of systems being able to boot a liveCD instead anyhow, but once upon a time you sometimes had to wade in with little more than sh, fsck, dd, and mount. Or you were booting from a non-random-access device and had too little memory to pre-load all the commands you wanted into a RAMdisk. Fortunate that there's a shell builtin for 'echo'. (If you could successfully mount the partition with /bin on it, you could get grep and ls that way, but if that was the partition, or the drive, that was too screwed up to mount, or if you were seeing what was on which partition to find the one containing /bin, sometimes it was just 'echo' wildcards, and the spooky sound of the desert wind pushing tumbleweeds around in /dev ...

Y'know, I hadn't really thought about those adventures much lately. Suddenly I find myself appreciating CD drives and larger RAM sizes ever so much more, in light of those memories.

(At least I never had to toggle in the bootstrap loader via front-panel switches.)

(no subject)

Date: 2011-07-28 05:46 pm (UTC)
From: [identity profile] theweaselking.livejournal.com
(Also: ls, seriously? Sure, if all you've got is sh and time - but if you're looking for a specific file SOMEWHERE in the file system you're still going to want to throw the output of "ls -R /" through grep.)

(no subject)

Date: 2011-07-28 05:53 pm (UTC)
From: [identity profile] mhoye.livejournal.com
I'm thinking an interviewer who won't stop at "find" isn't asking you to find a file somewhere on your system - they're asking you to find a file in whatever directory you're in, just to see if you answer "dir" or "I click the mouse."

(no subject)

Date: 2011-07-28 07:26 pm (UTC)
From: [identity profile] theweaselking.livejournal.com
The question is poorly paraphrased. The original was much closer to "here's a file name, how do you find it on your system" and it rapidly turned into "what's your process when something doesn't work the way you expect it to?"

And that last answer? Hilarious.

(I was neither the interviewer nor the candidate on this one.)

PS: interviewer and I were having fun:
"ls -R / > list.txt" and then use the built-in search of your editor of choice once the file has been created.
What if you have no text editors?
rsync the entire tree over to a machine that has them.
No rsync?
SFTP.
No network connection?
Boot the machine to a liveCD, and nobody's going to care because no network connection.
No CD drive?
USB.
No USB?
"What is this, a car's engine controller?" followed by "I really hope the file system is small, because it looks like ls -R / |more".
"What if you don't have more?"
"yank the disc and put it in a different computer."
"There's no disk!"
"You're pushing it. Why not just say 'no keyboard'?"
"No keyboard, then!"
"Smartphone emulates keyboard via bluetooth."
"...why is there bluetooth but no keyboard?"
"I don't know, man, this is YOUR system!"

(no subject)

Date: 2011-07-29 02:59 pm (UTC)
From: [identity profile] en-ki.livejournal.com
Wouldn't the traditional "you're maximally screwed" scenario be "you're sshed into a remote server and you've lost all your favorite binaries and it's a cheap desktop conversion so there's no LOM"?

(no subject)

Date: 2011-07-28 10:55 pm (UTC)
From: [identity profile] dglenn.livejournal.com
Ah, I had assumed that "using grep" meant precisely that (or "echo *|grep whatever" if even ls is missing[*]).

[*] Why yes, I have operated in Linux/Xenix/Unix environments where 'ls' was not installed. Though this has become less likely to come up again now that "live CDs" have largely replaced boot floppies.

(no subject)

Date: 2011-07-28 08:22 pm (UTC)
From: [identity profile] krfsm.livejournal.com
I think I'd ask for a bit more constraints, but my general idea of an answer would be pretty much those four, in that order (or yum rather than apt-get if it's a dead rat system).

(no subject)

Date: 2011-07-28 09:42 pm (UTC)
From: [identity profile] theweaselking.livejournal.com
Yeah, no, it's a GOOD answer set.

(no subject)

Date: 2011-07-28 10:19 pm (UTC)
From: [identity profile] skiriki.livejournal.com
Oh dear. Laughed way, way too much.

(no subject)

Date: 2011-07-29 03:04 am (UTC)
From: [identity profile] ydna.livejournal.com
I'd be the one asking the questions after "no grep".

(no subject)

Date: 2011-07-29 05:21 am (UTC)
From: [identity profile] aeduna.livejournal.com
I laughed hard :)

(no subject)

Date: 2011-07-29 06:27 am (UTC)
From: [identity profile] lirion.livejournal.com
I thought of you as I was reading this :>

(no subject)

Date: 2011-07-29 12:46 pm (UTC)
From: [identity profile] athelind.livejournal.com
Linux? More like WINux.

(Ouch. Athe, never, ever do that again.)

(no subject)

Date: 2011-07-29 07:52 pm (UTC)
From: [identity profile] xomox.livejournal.com
Easily do-able with shell built-ins:


findf()
{
local d=$1
local f=$2
local opwd=$PWD
cd $d
if [ 1 = $? ]; then
return
fi
for x in *; do
if [ $x = "." ] || [ $x = ".." ]; then
continue
fi
if [ $x = $f ]; then
echo "$d/$f"
fi
if [ -d $x ]; then
findf $d/$x $f
fi
done
cd $opwd
}

findf / foo

(Yes, this is full of bashisms, but it could be done with any shell.)

(no subject)

Date: 2011-07-30 03:26 pm (UTC)
From: [identity profile] rdmasters.livejournal.com
(Claps)

But also wonders what situation you got yourself into that required you to come up with this...

(no subject)

Date: 2011-08-01 04:29 am (UTC)
ext_8707: Taken in front of Carnegie Hall (bofh)
From: [identity profile] ronebofh.livejournal.com
Hmm, i wouldn't've picked ls simply because i don't use it to find files.  I use it to list files. If find isn't installed, the system is hosed and needs to be reinstalled.

Profile

theweaselking: (Default)theweaselking
Page generated Jul. 13th, 2025 02:44 am