Reputation: 275
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.
Upvotes: 2
Views: 8617
Reputation: 14147
If it is allowed to adjust the first ls -l
you could try to do:
ls -ld "$1"/* |awk '$3!=$4{print $9}' | xargs ls -l
In this case ls
will prefix the directory. But I don't know if this is portable behavior.
Upvotes: 0
Reputation: 212404
#!/bin/bash ls -l $1 | awk '$3!=$4{ system( "ls -l '$1'/" $9}'
Upvotes: 0
Reputation: 44394
Use awk system command:
ls -l $1 |awk '$3!=$4{system("ls -l " $9)}'
Upvotes: 2