6 deleted 16 characters in body
source | link

This is more of a challenge than anything: can it be done safely and elegantly in one line?

The main problem, both the patterns and the files are result of commands which may fail.

grep -Fxvf <(cmd-filter) <(cmd-list) | xargs -d "\n" gvfs-trash

  1. cmd-filter may return 0 to fail or output a bogus empty list if passed a bogus path (it's a knockoff remote ls).
  2. cmd-list is just a depth find. A failure here is not all bad, because even a typo just means the next, gvfs-trash program that will receive piped ouput, will not run on anything. It would be handy if a typo caused a failure though.

Obviously the main problem is the first. If it fails for any reason, or is empty because of a typo, all the files printed by cmd-list will be trashed. I'd like to avoid this, to say the least.

I've read on man that grep -f is supposed to fail grep if cmd-filter is empty, but i haven't experienced this in the above. If i replace cmd-filter by echo "" i get all the files in cmd-list. And what about failure from other reasons?

edit: thinking about this, this might because of the -v switch, which is necessary to invert the match to get the lines not in cmd-list. If so, i find it strange it finds the invert match of empty pattern list to be everything.

Anyway, since elegance may be impossible, and if there is no good response that is not 'just make a script you lazybones' i'd still mark correct a single line hack that uses tmp files or similar.

edit: Turned out that I myself 'failed' this challenge and used a long script (ab)using vars and process substitution to make this. Turned out that i didn't need to check both error status and if the stdout was empty in cmd-filter too, because in all error cases i found it was empty too.

This is more of a challenge than anything: can it be done safely and elegantly in one line?

The main problem, both the patterns and the files are result of commands which may fail.

grep -Fxvf <(cmd-filter) <(cmd-list) | xargs -d "\n" gvfs-trash

  1. cmd-filter may return 0 to fail or output a bogus empty list if passed a bogus path (it's a knockoff remote ls).
  2. cmd-list is just a depth find. A failure here is not all bad, because even a typo just means the next, gvfs-trash program that will receive piped ouput, will not run on anything. It would be handy if a typo caused a failure though.

Obviously the main problem is the first. If it fails for any reason, or is empty because of a typo, all the files printed by cmd-list will be trashed. I'd like to avoid this, to say the least.

I've read on man that grep -f is supposed to fail grep if cmd-filter is empty, but i haven't experienced this in the above. If i replace cmd-filter by echo "" i get all the files in cmd-list. And what about failure from other reasons?

edit: thinking about this, this might because of the -v switch, which is necessary to invert the match to get the lines not in cmd-list. If so, i find it strange it finds the invert match of empty pattern list to be everything.

Anyway, since elegance may be impossible, and if there is no good response that is not 'just make a script you lazybones' i'd still mark correct a single line hack that uses tmp files or similar.

edit: Turned out that I myself 'failed' this challenge and used a long script (ab)using vars and process substitution to make this. Turned out that i didn't need to check both error status and if the stdout was empty in cmd-filter too, because in all error cases i found it was empty too.

This is more of a challenge than anything: can it be done safely and elegantly in one line?

The main problem, both the patterns and the files are result of commands which may fail.

grep -Fxvf <(cmd-filter) <(cmd-list) | xargs -d "\n" gvfs-trash

  1. cmd-filter may return 0 to fail or output a bogus empty list if passed a bogus path (it's a knockoff remote ls).
  2. cmd-list is just a depth find. A failure here is not all bad, because even a typo just means the next, gvfs-trash program that will receive piped ouput, will not run on anything. It would be handy if a typo caused a failure though.

Obviously the main problem is the first. If it fails for any reason, or is empty because of a typo, all the files printed by cmd-list will be trashed. I'd like to avoid this, to say the least.

I've read on man that grep -f is supposed to fail grep if cmd-filter is empty, but i haven't experienced this in the above. If i replace cmd-filter by echo "" i get all the files in cmd-list. And what about failure from other reasons?

edit: thinking about this, this might because of the -v switch, which is necessary to invert the match to get the lines not in cmd-list. If so, i find it strange it finds the invert match of empty pattern list to be everything.

Anyway, since elegance may be impossible, and if there is no good response that is not 'just make a script you lazybones' i'd still mark correct a single line hack that uses tmp files or similar.

edit: I myself 'failed' this challenge and used a long script (ab)using vars and process substitution to make this. Turned out that i didn't need to check both error status and if the stdout was empty in cmd-filter too, because in all error cases i found it was empty too.

5 added 369 characters in body
source | link

This is more of a challenge than anything: can it be done safely and elegantly in one line?

The main problem, both the patterns and the files are result of commands which may fail.

grep -Fxvf <(cmd-filter) <(cmd-list) | xargs -d "\n" gvfs-trash

  1. cmd-filter may return 0 to fail or output a bogus empty list if passed a bogus path (it's a knockoff remote ls).
  2. cmd-list is just a depth find. A failure here is not all bad, because even a typo just means the next, gvfs-trash program that will receive piped ouput, will not run on anything. It would be handy if a typo caused a failure though.

Obviously the main problem is the first. If it fails for any reason, or is empty because of a typo, all the files printed by cmd-list will be trashed. I'd like to avoid this, to say the least.

I've read on man that grep -f is supposed to fail grep if cmd-filter is empty, but i haven't experienced this in the above. If i replace cmd-filter by echo "" i get all the files in cmd-list. And what about failure from other reasons?

edit: thinking about this, this might because of the -v switch, which is necessary to invert the match to get the lines not in cmd-list. If so, i find it strange it finds the invert match of empty pattern list to be everything.

Anyway, since elegance may be impossible, and if there is no good response that is not 'just make a script you lazybones' i'd still mark correct a single line hack that uses tmp files or similar.

edit: Turned out that I myself 'failed' this challenge and used a long script (ab)using vars and process substitution to make this. Turned out that i didn't need to check both error status and if the stdout was empty in cmd-filter too, because in all error cases i found it was empty too.

This is more of a challenge than anything: can it be done safely and elegantly in one line?

The main problem, both the patterns and the files are result of commands which may fail.

grep -Fxvf <(cmd-filter) <(cmd-list) | xargs -d "\n" gvfs-trash

  1. cmd-filter may return 0 to fail or output a bogus empty list if passed a bogus path (it's a knockoff remote ls).
  2. cmd-list is just a depth find. A failure here is not all bad, because even a typo just means the next, gvfs-trash program that will receive piped ouput, will not run on anything. It would be handy if a typo caused a failure though.

Obviously the main problem is the first. If it fails for any reason, or is empty because of a typo, all the files printed by cmd-list will be trashed. I'd like to avoid this, to say the least.

I've read on man that grep -f is supposed to fail grep if cmd-filter is empty, but i haven't experienced this in the above. If i replace cmd-filter by echo "" i get all the files in cmd-list. And what about failure from other reasons?

edit: thinking about this, this might because of the -v switch, which is necessary to invert the match to get the lines not in cmd-list. If so, i find it strange it finds the invert match of empty pattern list to be everything.

Anyway, since elegance may be impossible, and if there is no good response that is not 'just make a script you lazybones' i'd still mark correct a single line hack that uses tmp files or similar.

This is more of a challenge than anything: can it be done safely and elegantly in one line?

The main problem, both the patterns and the files are result of commands which may fail.

grep -Fxvf <(cmd-filter) <(cmd-list) | xargs -d "\n" gvfs-trash

  1. cmd-filter may return 0 to fail or output a bogus empty list if passed a bogus path (it's a knockoff remote ls).
  2. cmd-list is just a depth find. A failure here is not all bad, because even a typo just means the next, gvfs-trash program that will receive piped ouput, will not run on anything. It would be handy if a typo caused a failure though.

Obviously the main problem is the first. If it fails for any reason, or is empty because of a typo, all the files printed by cmd-list will be trashed. I'd like to avoid this, to say the least.

I've read on man that grep -f is supposed to fail grep if cmd-filter is empty, but i haven't experienced this in the above. If i replace cmd-filter by echo "" i get all the files in cmd-list. And what about failure from other reasons?

edit: thinking about this, this might because of the -v switch, which is necessary to invert the match to get the lines not in cmd-list. If so, i find it strange it finds the invert match of empty pattern list to be everything.

Anyway, since elegance may be impossible, and if there is no good response that is not 'just make a script you lazybones' i'd still mark correct a single line hack that uses tmp files or similar.

edit: Turned out that I myself 'failed' this challenge and used a long script (ab)using vars and process substitution to make this. Turned out that i didn't need to check both error status and if the stdout was empty in cmd-filter too, because in all error cases i found it was empty too.

4 added 231 characters in body
source | link

This is more of a challenge than anything: can it be done safely and elegantly in one line?

The main problem, both the patterns and the files are result of commands which may fail.

grep -Fxvf <(cmd-filter) <(cmd-list) | xargs -d "\n" gvfs-trash

  1. cmd-filter may return 0 to fail or output a bogus empty list if passed a bogus path (it's a knockoff remote ls).
  2. cmd-list is just a depth find. A failure here is not all bad, because even a typo just means the next, gvfs-trash program that will receive piped ouput, will not run on anything. It would be handy if a typo caused a failure though.

Obviously the main problem is the first. If it fails for any reason, or is empty because of a typo, all the files printed by cmd-list will be trashed. I'd like to avoid this, to say the least.

I've read on man that grep -f is supposed to fail grep if cmd-filter is empty, but i haven't experienced this in the above. If i replace cmd-filter by echo "" i get all the files in cmd-list. And what about failure from other reasons?

edit: thinking about this, this might because of the -v switch, which is necessary to invert the match to get the lines not in cmd-list. If so, i find it strange it finds the invert match of empty pattern list to be everything.

Anyway, since elegance may be impossible, and if there is no good response that is not 'just make a script you lazybones' i'd still mark correct a single line hack that uses tmp files or similar.

This is more of a challenge than anything: can it be done safely and elegantly in one line?

The main problem, both the patterns and the files are result of commands which may fail.

grep -Fxvf <(cmd-filter) <(cmd-list) | xargs -d "\n" gvfs-trash

  1. cmd-filter may return 0 to fail or output a bogus empty list if passed a bogus path (it's a knockoff remote ls).
  2. cmd-list is just a depth find. A failure here is not all bad, because even a typo just means the next, gvfs-trash program that will receive piped ouput, will not run on anything. It would be handy if a typo caused a failure though.

Obviously the main problem is the first. If it fails for any reason, or is empty because of a typo, all the files printed by cmd-list will be trashed. I'd like to avoid this, to say the least.

I've read on man that grep -f is supposed to fail grep if cmd-filter is empty, but i haven't experienced this in the above. If i replace cmd-filter by echo "" i get all the files in cmd-list. And what about failure from other reasons?

Anyway, since elegance may be impossible, and if there is no good response that is not 'just make a script you lazybones' i'd still mark correct a single line hack that uses tmp files or similar.

This is more of a challenge than anything: can it be done safely and elegantly in one line?

The main problem, both the patterns and the files are result of commands which may fail.

grep -Fxvf <(cmd-filter) <(cmd-list) | xargs -d "\n" gvfs-trash

  1. cmd-filter may return 0 to fail or output a bogus empty list if passed a bogus path (it's a knockoff remote ls).
  2. cmd-list is just a depth find. A failure here is not all bad, because even a typo just means the next, gvfs-trash program that will receive piped ouput, will not run on anything. It would be handy if a typo caused a failure though.

Obviously the main problem is the first. If it fails for any reason, or is empty because of a typo, all the files printed by cmd-list will be trashed. I'd like to avoid this, to say the least.

I've read on man that grep -f is supposed to fail grep if cmd-filter is empty, but i haven't experienced this in the above. If i replace cmd-filter by echo "" i get all the files in cmd-list. And what about failure from other reasons?

edit: thinking about this, this might because of the -v switch, which is necessary to invert the match to get the lines not in cmd-list. If so, i find it strange it finds the invert match of empty pattern list to be everything.

Anyway, since elegance may be impossible, and if there is no good response that is not 'just make a script you lazybones' i'd still mark correct a single line hack that uses tmp files or similar.

3 added 83 characters in body
source | link
2 deleted 90 characters in body
source | link
1
source | link