Hi everybody!

Help me please to figure out the comand that I need to use to find a file and open it at same time

for example:

root@serg-PORTEGE-Z835:~# locate bash_profile
/usr/share/doc/adduser/examples/adduser.local.conf.examples/skel/dot.bash_profile

and lets say I want to open this file, but I don't want to use cd and go all the way down to that file.

Is ther any easy and short way to do this?

Recommended Answers

find / -name 'bash_profile' -exec cat {} \;
Beware you might get more than one file

Jump to Post

All 4 Replies

find / -name 'bash_profile' -exec cat {} \;
Beware you might get more than one file

how about if the file that I'm looking is a text file and I want to open it in vi editor?

Just replace the cat with vi.

I usually use the "less" command, which will let me look at the file, and optionally edit it if I want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.