Need help with regular expressions

4 views
Skip to first unread message

Great Avenger Singh

unread,
Feb 1, 2015, 6:43:51 AM2/1/15
to iit...@googlegroups.com
I am making a script that will show the list of JPG files and saving
that list with xargs for further processing. When I am using echo to
get the file names it adds "./" in the start of every filename.

find . -type f -iname '*.JPG' -print0 |
xargs -0 -n 1 -P 1 -I {} \
echo The file is \'{}\'!

It is showing following output:

The file is './DSC_7555.JPG'!

How to remove "./" in the start of every file name?

--

Thanks
Arshpreet Singh
http://arshpreetsingh.wordpress.com/
It’s not that I’m so smart, it’s just that I stay with problems longer.
-Albert Einstein
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/

Ashim Kapoor

unread,
Feb 1, 2015, 8:19:46 AM2/1/15
to iit...@googlegroups.com
On Sun, Feb 1, 2015 at 5:13 PM, Great Avenger Singh <ars...@gmail.com> wrote:
I am making a script that will show the list of JPG files and saving
that list with xargs for further processing. When I am using echo to
get the file names it adds "./" in the start of every filename.

    find . -type f -iname '*.JPG' -print0 |
    xargs -0 -n 1 -P 1 -I {} \
    echo The file is \'{}\'!

It is showing following output:

The file is './DSC_7555.JPG'!

How to remove "./" in the start of every file name?



find . -type f -iname '*.JPG' -print0 |xargs -0 -n 1 -P 1 -I {} \echo The file is \'{}\'! | sed "s/\.\///"


 
--

Thanks
Arshpreet Singh
http://arshpreetsingh.wordpress.com/
It’s not that I’m so smart, it’s just that I stay with problems longer.
-Albert Einstein
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/

--
--
Mailing list guidelines and other related articles: http://lug-iitd.org/Footer

---
You received this message because you are subscribed to the Google Groups "Linux User Group @ IIT Delhi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iitdlug+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages