LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-08-2016, 10:35 PM   #1
perfection
Member
 
Registered: Nov 2015
Distribution: Slackware64-Current
Posts: 58

Rep: Reputation: Disabled
Question Find to File.txt no Path


I would like to know how to send the result of the find without the path

I Try:
Code:
find * -type f > List1.txt
find * -exec echo "{}" >> List2.txt \;

Results:
x86_64-kde/kdepim/kidentitymanagement-16.04.3-x86_64-1alien.txz
x86_64-kde/kdepim/libksieve-16.04.3-x86_64-1alien.txz
x86_64-kde/kdepim/libgravatar-16.04.3-x86_64-1alien.txz
x86_64-kde/kdepim/kontactinterface-16.04.3-x86_64-1alien.txz
x86_64-kde/kdepim/akonadi-calendar-16.04.3-x86_64-1alien.txz
I would like a result like this:
Code:
kidentitymanagement-16.04.3-x86_64-1alien.txz
libksieve-16.04.3-x86_64-1alien.txz
libgravatar-16.04.3-x86_64-1alien.txz
kontactinterface-16.04.3-x86_64-1alien.txz
akonadi-calendar-16.04.3-x86_64-1alien.txz
 
Old 08-08-2016, 10:44 PM   #2
chris.willing
Member
 
Registered: Jun 2014
Location: Brisbane, Australia
Distribution: Slackware,LFS
Posts: 914

Rep: Reputation: 619Reputation: 619Reputation: 619Reputation: 619Reputation: 619Reputation: 619
find * -type f | rev | cut -d '/' -f 1 | rev
 
1 members found this post helpful.
Old 08-08-2016, 10:48 PM   #3
perfection
Member
 
Registered: Nov 2015
Distribution: Slackware64-Current
Posts: 58

Original Poster
Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by chris.willing View Post
find * -type f | rev | cut -d '/' -f 1 | rev
WOW! It worked! Thank you so much!
 
Old 08-08-2016, 11:27 PM   #4
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
find * -type f -printf '%f\n'
 
3 members found this post helpful.
Old 08-08-2016, 11:39 PM   #5
chris.willing
Member
 
Registered: Jun 2014
Location: Brisbane, Australia
Distribution: Slackware,LFS
Posts: 914

Rep: Reputation: 619Reputation: 619Reputation: 619Reputation: 619Reputation: 619Reputation: 619
Quote:
Originally Posted by Diantre View Post
find * -type f -printf '%f\n'
Yep, more concise and a little bit faster
 
Old 08-09-2016, 05:13 AM   #6
perfection
Member
 
Registered: Nov 2015
Distribution: Slackware64-Current
Posts: 58

Original Poster
Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by Diantre View Post
find * -type f -printf '%f\n'
It worked!
 
Old 08-09-2016, 05:44 AM   #7
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Diantre --

Thanks !

That's a keeper.

This
Code:
find . -type f -printf '%f\n'
Is MUCH better than the old-way I USED to do it:

Code:
for File in $(find . -type f -print)
do
   [ ! -z "$File" ] && basename $File || continue
done
Thanks again !

I'll be using your find..printf '%f\n' construct from now on -- there are a LOT of handy printf args for the `find` command in there !

-- kjh( gotta remember to review the man pages from time-to-time )
 
  


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
Can't find a file in cmake.txt chiara90 Linux - Newbie 2 03-19-2014 02:02 PM
Compare file extension from two different txt file and find the differences. Neal000 Programming 6 08-28-2012 02:03 PM
find string in txt file Glenn_UOI Programming 6 10-07-2011 09:50 AM
Find a file path and directory path ak.lokesh Linux - Newbie 3 02-19-2009 12:37 PM
using commands to output path, filename and info to a txt file bob_man_uk Linux - General 3 05-11-2006 02:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:14 AM.

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