Run(``),and how to add $

I ran this code in linux shell.
And I want to filter the last column which is smaller than 1000.

cat test.bed
999981  999981  HES4    981
1173903 1173903 TTLL10  15903
1173903 1173903 TTLL10  1903
1287109 1287109 SCNN1D  6892
1331314 1331314 TAS1R3  314
1449914 1449914 ATAD3C  4087
1471769 1471769 ATAD3B  2769
1540350 1540350 TMEM240 350
1659012 1659012 CDK11B  12

When I ran in julia first,I made it.

julia> run(pipeline(`cat test.bed`,`awk '$NF<1000'`))
999981  999981  HES4    981
1331314 1331314 TAS1R3  314
1540350 1540350 TMEM240 350
1659012 1659012 CDK11B  12
Base.ProcessChain(Base.Process[Process(`cat test.bed`, ProcessExited(0)), Process(`awk '$NF<1000'`, ProcessExited(0))], Base.DevNull(), Base.DevNull(), Base.DevNull())

But I want change 1000 into $number,and failed.

number=1000
julia>run(pipeline(`cat test.bed`,`awk '$NF<$number'`))
999981  999981  HES4    981
1659012 1659012 CDK11B  12
Base.ProcessChain(Base.Process[Process(`cat test.bed`, ProcessExited(0)), Process(`awk '$NF<$number'`, ProcessExited(0))], Base.DevNull(), Base.DevNull(), Base.DevNull())

They were different.How to do to add $number in my second code to acheive that fact in my first code?Thanks.

julia> run(pipeline(`cat test.bed`,`awk "\$NF<$number"`))
999981  999981  HES4    981
1331314 1331314 TAS1R3  314
1540350 1540350 TMEM240 350
1659012 1659012 CDK11B  12

However, note that Julia is a perfectly good language for string processing, with built-in regular expressions and many libraries for parsing tabulated data, so it’s fairly wasteful and unnecessary to pipe out to awk for things like this. It can be tempting to stick with familiar tools, but in the long run you’ll be much better off learning to use Julia when programming in Julia.

3 Likes