Avatar of rgb192
rgb192Flag for United States of America

asked on 

ssh where I know a portion of the filename

linux ssh
search all folders for a mysql database backup file

find / -name '*.sql' -o -name '*.bak'

produces many results

I know a portion of the filename


file is named


*hello*.bak

where it could be
1hello2.bak
Linux

Avatar of undefined
Last Comment
rgb192
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

So why not just

find /  -name '*hello*.bak'

?
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

If it can only be a single character you can use:

find /  -name ?hello?.bak
ASKER CERTIFIED SOLUTION
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Darr247
Darr247
Flag of United States of America image

Why not try

# CD /

# locate *.bak

instead of find?
Avatar of Mysidia
Mysidia
Flag of United States of America image

find / -name '*.sql' -o -name '*.bak'  > tempfile.1

grep -i .hello. tempfile.1
Avatar of amitnepal
amitnepal
Flag of United States of America image

find / -name "*.sql" | egrep "hello|bak"
Avatar of Crunched
Crunched

There won't be many (if any) other files with 'hello' in them, so try:
locate hello

Open in new window


This will give you a listing of all files with 'hello' in the name and their locations.  This must be an exam question or something as someone else just recently asked the exact same question (and accepted my answer above as the solution :p )
Avatar of amitnepal
amitnepal
Flag of United States of America image

locate will sometimes not locate recent files because the database is not updated. If you want to use locate to find that file, try doing updatedb before you do locate.

eg. updatedb
locate hello

Thanks
Avatar of rgb192
rgb192
Flag of United States of America image

ASKER

Best targeted results.  Thanks
Linux
Linux

Linux is a UNIX-like open source operating system with hundreds of distinct distributions, including: Fedora, openSUSE, Ubuntu, Debian, Slackware, Gentoo, CentOS, and Arch Linux. Linux is generally associated with web and database servers, but has become popular in many niche industries and applications.

71K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo