Skip to main content

Timeline for How to "less" a file named "-"?

Current License: CC BY-SA 3.0

26 events
when toggle format what by license comment
May 23, 2017 at 12:40 history edited CommunityBot
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Apr 13, 2017 at 12:37 history edited CommunityBot
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Jun 22, 2015 at 7:58 history edited haylem CC BY-SA 3.0
added 445 characters in body
Jun 18, 2015 at 2:57 comment added Kevin @Kwaio this is certainly neither the most portable nor the most command-independent solution; in fact, it doesn't even work on the file in the question. ./- is the correct answer. -- is only "best practice" when using a wildcard at the start of the file name on commands that recognize it (which is not all, and for those gnu utilities that do, their counterparts on other systems may not).
Jun 17, 2015 at 12:29 comment added haylem @StéphaneChazelas: Yes I was considering what to do. I'll edit when I get home.
Jun 17, 2015 at 11:56 comment added Stéphane Chazelas You may want to delete the answer (or move it to the other question as there are useful references in here) or make it clear that it doesn't apply to this particular case (and maybe explain why which would be even more useful).
Jun 17, 2015 at 11:31 comment added haylem @MichałPolitowski: Yes, I had misread the question, I didn't realize OP asked for a file named exactly -, I was thinking of filenames starting with -.
Jun 17, 2015 at 11:11 comment added Michał Politowski As Stéphane says, this does not answer the question. less -- - will still try to read from stdin.
Jun 17, 2015 at 10:22 comment added Stéphane Chazelas That answer applies to arguments that look like options. It's not the case for - which is not an option. Using ./- or redirection when possible is generally a better approach as it avoids other kinds of problems like the foo=bar of awk or that -. See also unix.stackexchange.com/a/56370, unix.stackexchange.com/a/110756
Jun 17, 2015 at 10:12 history edited haylem CC BY-SA 3.0
added 223 characters in body
Jun 17, 2015 at 10:06 history edited haylem CC BY-SA 3.0
added 223 characters in body
Jun 17, 2015 at 10:04 comment added haylem @EtanReisner: But you're right, I'll clarify my wording.
Jun 17, 2015 at 10:03 comment added haylem @Etan: You're right, it's not, but it's a convention for shell utilities and for tools to respect that convention for consistency.
Jun 17, 2015 at 10:02 comment added Etan Reisner This isn't a shell feature at all. The shell doesn't get involved here (except for built-in commands but that's shell involvement as a command not as the running shell).
Jun 17, 2015 at 9:49 history edited haylem CC BY-SA 3.0
added 872 characters in body
Jun 17, 2015 at 9:43 history edited haylem CC BY-SA 3.0
added 872 characters in body
Jun 17, 2015 at 9:43 vote accept fedorqui
Jun 17, 2015 at 10:28
Jun 17, 2015 at 9:39 comment added haylem @Kwai: the Open Group is an even better one :)
Jun 17, 2015 at 9:39 comment added haylem @fedorqui: I added the information. It's a standard convention specified by the Open Group shell command language specs, so most compliant shells would (and should) support it. Anything else just looks like dodgy hackery in my opinion. (though it's good to have another way if that's not supported, of course)
Jun 17, 2015 at 9:37 history edited haylem CC BY-SA 3.0
added 872 characters in body
Jun 17, 2015 at 9:37 comment added mveroone (nice edit, I suppose bash manpage is a good enough reference ^^)
Jun 17, 2015 at 9:36 comment added mveroone Except for cyberciti.biz articles, I don't know. it's just what I have always been taught to do by mentors/teachers/red hat training courses
Jun 17, 2015 at 9:33 history edited haylem CC BY-SA 3.0
added 872 characters in body
Jun 17, 2015 at 9:33 comment added fedorqui @Kwaio any reference about the "best practice"? Just feel curious about it.
Jun 17, 2015 at 9:32 comment added mveroone +1 : Most portable and command-independant solution, easy to remember, and considered the "best practice"
Jun 17, 2015 at 9:28 history answered haylem CC BY-SA 3.0