LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-14-2022, 06:15 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix, MX
Posts: 327

Rep: Reputation: Disabled
How find file name by pattern to immediately use it again for the next time


How do we find file names by pattern to use them, for copy/move or delete etc, again for the next time in one line CLI, e.g.
Code:
$ ls

.hello-577
.world-999
.foo-444
jjj
hello
world
foo
kkk
lll
so must get all .hello-577 .world-999 .foo-444 hello world foo to use them in the operation said

e.g. there's BAK directory so as if copy operation:
Code:
cp .hello-577 .world-999 .foo-444 hello world foo BAK
e.g. they're removed so as if operating:
Code:
rm .hello-577 .world-999 .foo-444 hello world foo
Please sincere help is invaluable
 
Old 11-14-2022, 07:42 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 10,701

Rep: Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062
The standard answer would be find -exec.
 
1 members found this post helpful.
Old 11-15-2022, 01:26 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,387
Blog Entries: 1

Rep: Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665Reputation: 1665
@OP Where is the pattern?
 
Old 11-15-2022, 05:06 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,958

Rep: Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173Reputation: 3173
As usual, what have you tried and where are you stuck?
 
Old 11-15-2022, 10:10 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,736
Blog Entries: 13

Rep: Reputation: 4784Reputation: 4784Reputation: 4784Reputation: 4784Reputation: 4784Reputation: 4784Reputation: 4784Reputation: 4784Reputation: 4784Reputation: 4784Reputation: 4784
This is from one of the LQ FAQs and would prove to be very helpful for you:

http://www.catb.org/~esr/faqs/smart-questions.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] [BASH][SED] Find pattern and replace it's [pattern's] last character czezz Programming 10 10-22-2020 08:43 AM
find the pattern in a file where both pattern and file have differnt number of lines and space wedtorque Linux - Newbie 2 05-31-2017 10:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration