Domanda

On unix system, I need to open the files that satisfy the following criterion:

awk '{FS=",";if(($1>0.8)&&($2<0.2)){print NR-1"*png"}}' scindex_rscindex

Whose output is

287*png 288*png

I need to open these files in eog.

awk '{FS=",";if(($1>0.8)&&($2<0.2)){print NR-1"*png"}}' scindex_rscindex |eog doesnot work. Please guide.

È stato utile?

Soluzione

eog does not read file names from standard input. You are looking for

eog $(awk '{FS=",";if(($1>0.8)&&($2<0.2)){print NR-1"*png"}}' scindex_rscindex)

It is not clear whether or not you expect the output from the Awk script to be interpreted as shell wildcards, or as literal file names. If indeed they are literal file names (with extremely poorly chosen names, given how they will complicate processing in the shell), you should quote them somehow.

Altri suggerimenti

If you want to just use output of a command as argument for another do this:

another $(command)

Like:

eog $(awk '{FS=",";if(($1>0.8)&&($2<0.2)){print NR-1"*png"}}' scindex_rscindex)

If you use , this could be enough. But under other , if you want shell doing wildcard development, you may have to:

eval "eog $(
  awk '{FS=",";if(($1>0.8)&&($2<0.2)){print NR-1"*png"}}')"
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top