Home Finding a filetype in current directory and subdirectory, including hidden files. (Homework)
Reply: 0

Finding a filetype in current directory and subdirectory, including hidden files. (Homework)

user826
1#
user826 Published in April 24, 2018, 6:42 am

With bash, I am needing to find all gifs in my current directory and subdirectories, and display them in a specific way. I have to include hidden files as well, and I am not allowed to use grep (or its subsidiaries - fgrep and such) or basename. I am running Ubuntu 14.04 through a virtual machine (VirtualBox via Vagrant if that matters) without a GUI. My current script looks like this:

#!/bin/bash
ls -a | find $directory -type f -name "*.gif" | rev | cut -d/ -f1 | rev | cut -d. -f1 | sort -f

This has mostly done what I need, especially with regard to formatting, but when I changed one of the gifs to a hidden file, it was no longer visible - there was an extra empty line, almost as if the file name was written in invisible ink. Does anyone know why it's doing this?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302829 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO