Find command question
find -type f -name "root"
Say I was using the above command to find a file, how would I adjust the command to make each result have the file type displayed? I'm guessing it would involve piping the output to the file command somehow, but not sure? |
What do you mean how would you get it to display the file type? You already limited to type f. Do you mean how do I check if it is executable or something else? I suspect the -ls flag maybe the answer but not entirely certain what it is you are after.
|
Code:
find . -type f -exec file {} \; |
You'll want to use the -exec option for find so it can call file for you. See the manual page for details.
Code:
man find PS. The first argument to find needs to be a path. |
the type is file, the extension to tell one what type of file it is is a different matter, it seems that yes that can get confusing.
Code:
find -type f -iname "root.*" Quote:
Code:
find -type f -iname "*root.*" Quote:
the Code:
-iname Quote:
|
Quote:
./bar: ASCII text ./checker: POSIX shell script, ASCII text executable |
Quote:
file type is an ambiguous word here i think. if that was just a hey check out what this can do post, then thanks, I cannot run it to see, I'm in windows .... |
Nah, not "check what this can do."
I didn't fully understand what you meant with the type is file (obviously, but there are different files) and what you meant with extensions (which are not needed nor recommended, at least as far shell scripts are concerned). Hence i quoted that part, not the explanations about find usage (which never hurts, imho). |
Quote:
left over windows idealism I think is the source of my take on what s/he meant by file type. Though their is the .conf .ini and other such file types within Linux too one needs to take into consideration here. Now that my brain is thinking Linux and not Windows. :D |
Quote:
|
Whilst I have your attention, how about this one:
What command(s) would I use to extract the IP only from this URL? https://192.168.3.4/random/directories/here/ |
Quote:
And to get the IP, you could use awk, split, grep, sed, or a combination of those things...along with others. What have you done/tried so far? |
The file command takes multiple (file-)arguments, so you can do
Code:
find . -type f -exec file {} + |
Quote:
I've tried a few of those commands, and also cut. Genuinely stumped on this. It's not homework, it's a kind of quiz, that permits "research" so I don't think I'm doing anything wrong. Not looking for exact answers, just a nudge in the right direction. I guess I should just read the man pages for all the aforementioned commands a bit more thoroughly |
Quote:
http://shop.oreilly.com/product/9781565922259.do As a hint, look at the "-F" flag for awk, then look at your input string. See anything common at the beginning/end of what you're after that you can use as a field-separator? |
All times are GMT -5. The time now is 07:56 AM. |