0

Hello guys I'm using the find command to find the .apk files in a directory. But the output of the find command is **./**foo.apk.

I don't want to have this ./.

cd output/dist
output_apk=`find ./ -name "*.apk" -print0`
echo "$output_apk"

The output is ./foo.apk. I have try the sed command with no luck.

root-expert
  • 360
  • 2
  • 5

1 Answers1

2
find output/dist -name "*.apk" |
sed 's%^output/dist/%%'

This also avoids the useless cd and removes the erroneous -print0. If you are not piping into a program which requires null-terminated input, this option is wrong.

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • Can I use this with the variable output_apk= ? – root-expert Jan 25 '15 at 17:18
  • Of course you can assign the result to a variable if you like, although capturing just so you can `echo` it is a [useless use of `echo`](http://www.iki.fi/era/unix/award.html#echo) – tripleee May 17 '18 at 10:15