jqnatividad / qsv

CSVs sliced, diced & analyzed.
The Unlicense
2.26k stars 63 forks source link

`search`: add `--not-one` flag for not using exit code 1 when no match #1810

Closed rzmk closed 3 weeks ago

rzmk commented 3 weeks ago

Allows a user to keep using exit code 0 even if there are no matches.

Example

Say I have a file data.csv:

Name,Department,Salary,Phone
,IT,71000,
Alice Johnson,HR,65000,294-203-0222
Bob Anderson,IT,71000,
Jane Smith,Finance,75000,
John Doe,IT,60000,850-240-4924

Now I want to search a value but it doesn't exist:

qsv search 'Jake' data.csv

We'll get the headers back (so no matches):

Name,Department,Salary,Phone

And when we run:

echo $?

The value returned is the exit code, in this case 1. But by using --not-one we get 0.

jqnatividad commented 3 weeks ago

Thanks @rzmk !