- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Find Command + Case Insensitive
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2005 08:19 AM
10-31-2005 08:19 AM
Find Command + Case Insensitive
I have:
DIRS="DIR1 DIR2 DIR3 DIR4"
for dir in $DIRS; do
echo -e "$dir: " && find . \( -name "${dir}_*" -o -name "c-*" \) -ctime -1 -exec ls -l {} \; |awk '/^-/ {total += $5} END {printf "%15.2f\n",total}'
done
Which mostly works, it just has 1 problem. I need the name to not be case sensitive. I thought -iname would do the trick, but it does not seem to be valid. I would greatly appreciate some help.
The reason it needs to be case insensitive is because 1 dir is lowercase, and the files in it are uppercase.
Ex:
dir = test
file = TEST_1122333
Thanks!
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2005 08:27 AM
10-31-2005 08:27 AM
Re: Find Command + Case Insensitive
http://hpux.cs.utah.edu/hppd/hpux/Gnu/findutils-4.2.20/
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2005 08:28 AM
10-31-2005 08:28 AM
Re: Find Command + Case Insensitive
You might want to download the gnu findutils available from http://hpux.cs.utah.edu/hppd/hpux/Gnu/findutils-4.2.20/ or your nearest porting and archiving centre. it supports -iname.
Enjoy.
- Tags:
- findutils
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2005 08:37 AM
10-31-2005 08:37 AM
Re: Find Command + Case Insensitive
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2005 08:38 AM
10-31-2005 08:38 AM
Re: Find Command + Case Insensitive
Yet another alternative is to craft your own using perl. 'stat() will yield the values for the 'ls' output. The 'File::Find' module will drive the recursive directory lookup.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2005 08:57 AM
10-31-2005 08:57 AM
Re: Find Command + Case Insensitive
-name "[Dd][Ii][Rr]1"
Here's a function that will do that:
#!/usr/bin/sh
make_regex()
{
typeset -u UC="${1}"
typeset -i LEN=$(expr length "${UC}")
typeset -i I=1
typeset OUT=''
while [[ ${I} -le ${LEN} ]]
do
typeset U1=$(echo ${UC} | cut -c ${I}-${I})
typeset L1=$(echo ${U1} | tr "[A-Z]" "[a-z]")
if [[ "${U1}" != "${L1}" ]] # is alpha
then
OUT="${OUT}[${U1}${L1}]"
else
OUT="${OUT}${U1}"
fi
((I += 1))
done
echo "${OUT}"
return 0
} # make_regex
# use it like this:
while [[ ${#} -ge 1 ]]
do
X=$(make_regex "${1}")
echo "${1} ==> ${X}"
shift
done