You are not logged in.

#1 2011-02-01 17:13:43

CulleyS
Member
Registered: 2010-03-02
Posts: 18

[SOLVED] Open files, ignore directories

Hello,

I'm wondering if there is a shortcut to open files from the command line, while ignoring directories.  For example,  "<program> <filename>" to open said file in that program.  However, what about if I want to open ALL files in that directory with said program?  If I type "<program> *" or "<program> ." it will open all files, but in certain scenarios, I wll receive an error message saying something along the lines of "cannot open directories in <program>."  So, I was curious if there was a shorthand for opening all files in a directory, but exclude subdirectories. 

Thanks,
Culley

Last edited by CulleyS (2011-02-01 23:09:51)

Offline

#2 2011-02-01 22:39:13

hexanol
Member
From: Canaduh
Registered: 2009-08-04
Posts: 95

Re: [SOLVED] Open files, ignore directories

This will do it:

find . -maxdepth 1 -type f -exec <program> {} +

Offline

#3 2011-02-01 22:56:51

CulleyS
Member
Registered: 2010-03-02
Posts: 18

Re: [SOLVED] Open files, ignore directories

Beautiful, I was messing with find, but wasn't making any headway.

Thanks!

Offline

#4 2011-02-01 23:55:32

hexanol
Member
From: Canaduh
Registered: 2009-08-04
Posts: 95

Re: [SOLVED] Open files, ignore directories

You're welcome.

That said, the find command might appears a bit complex at first, but once you get accustomed to it, it's a really useful tool.

Offline

Board footer

Powered by FluxBB