Skip to main content
24 events
when toggle format what by license comment
Jul 7, 2021 at 9:54 comment added muru @alper as two answers there say, it's from the moreutils package. You'll need to install that package.
Jul 7, 2021 at 0:16 comment added muru It's a normal command like any other, so you can use it in any reasonable shell.
Jul 6, 2021 at 23:17 comment added alper Can we use ifne in zsh shell? @muru
Jul 6, 2021 at 23:09 history closed muru
CommunityBot
Duplicate of How to check if a pipe is empty and run a command on the data if it isn't?
Jul 6, 2021 at 8:26 history edited AdminBee
Re-Tag according fo info given in comments
Jul 6, 2021 at 7:56 review Close votes
Jul 6, 2021 at 23:18
Jul 6, 2021 at 7:41 comment added muru Seems you want git ... | ifne less
Jul 6, 2021 at 7:40 history edited muru
[Edit removed during grace period]
Jul 5, 2021 at 20:01 comment added alper @ilkkachu I tagged bash by mistake by taking tags from the linked related question, and when I realize my mistake it was too late to change it. I am sorry for this. // In general I was redirecting ls or git diff results into less -R. I just wanted to ignore redirecting into less -R if the command's output is empty and do nothing
Jul 5, 2021 at 19:45 comment added ilkkachu Technically, the answer to the question in the title, to "check if output is non-empty, and print it if it is", is to just print it unconditionally. Since printing an empty output doesn't do anything. But that's not exactly what you want.
Jul 5, 2021 at 19:43 comment added ilkkachu @alper, you're using Zsh, but your question is tagged with bash in particular and not zsh?
Jul 5, 2021 at 18:41 answer added user480335 timeline score: 1
Jul 5, 2021 at 18:24 comment added Kusalananda Note that this question would have had a totally different set of answers, had you mentioned that you used the zsh shell.
Jul 5, 2021 at 18:22 comment added Kusalananda shopt is a builtin utility in the bash shell. You tagged your question with the bash tag.
Jul 5, 2021 at 17:29 comment added alper Where can I download shopt? // E: Unable to locate package shopt // please note that I am using zsh shell
Jul 5, 2021 at 15:44 comment added Kusalananda shopt -s nullglob dotglob; set -- *; [ "$#" -eq 0 ] && echo 'no files'
Jul 5, 2021 at 15:20 vote accept alper
Jul 5, 2021 at 15:05 history edited alper CC BY-SA 4.0
deleted 399 characters in body
Jul 5, 2021 at 15:03 comment added alper For the purpose of the question I can remove ls section, since it leads another question as unix.stackexchange.com/questions/657078/… // For @Stephen Kitt's answer than should we first set set -- * ?
Jul 5, 2021 at 14:56 comment added Kusalananda Note that for the specific case of checking the number of names in a directory, ls is not the best tool for the job. It would be better to set -- * (possibly setting nullglob and/or dotglob in bash first) and then look at "$#".
Jul 5, 2021 at 14:55 history edited alper CC BY-SA 4.0
added 407 characters in body
Jul 5, 2021 at 14:51 answer added Stephen Kitt timeline score: 3
Jul 5, 2021 at 14:47 answer added AdminBee timeline score: 9
Jul 5, 2021 at 14:39 history asked alper CC BY-SA 4.0