Search code examples
bashunixawkls

How to do an ls command on output from an awk field


This takes a directory as a parameter:

#!/bin/bash

ls -l $1 |awk '$3!=$4{print $9}' 

Now what I need is to be able to do ANOTHER ls -l on the just the files that are found from the awk statement.

Yeah, it sounds dumb, and I know of like 3 other ways to do this, but not with awk.


Solution

  • #!/bin/bash
    
    ls -l $1 | awk '$3!=$4{ system( "ls -l '$1'/" $9}'