Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Lets say i have two files in the current folder:
file1.xyz
file2.xyz
Quote:
$find . -name "*.xyz" | xargs basename -s ".xyz"
i was hoping to get
Quote:
file1
file2
but this is the output i got
Quote:
basename: invalid option -- 's'
this is the version of basename i have
Quote:
$basename --help
Usage: basename NAME [SUFFIX]
or: basename OPTION
Print NAME with any leading directory components removed.
If specified, also remove a trailing SUFFIX.
--help display this help and exit
--version output version information and exit
Examples:
basename /usr/bin/sort Output "sort".
basename include/stdio.h .h Output "stdio".
Report basename bugs to bug-coreutils@gnu.org
GNU coreutils home page: http://www.gnu.org/software/coreutils/
General help using GNU software: http://www.gnu.org/gethelp/
For complete documentation, run: info coreutils 'basename invocation'
[khorseik@ntu03 output]$ basename --version
basename (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
DESCRIPTION
Print NAME with any leading directory components removed. If
specified, also remove a trailing SUFFIX.
Mandatory arguments to long options are mandatory for short options
too.
-a, --multiple
support multiple arguments and treat each as a NAME
-s, --suffix=SUFFIX
remove a trailing SUFFIX; implies -a
....
....
GNU coreutils 8.26 January 2017 BASENAME(1)
Yes, this one works as what i want. But the problem, i need to use xargs as part of my next step of work.
So i guess i would need to find a workaround with the -exec
Oh, i read that.
And truth to be told: i am not that much in the subject that i could advise or explain it at all.
My post was rather focused at the OP, so he knows that some folks have strong opinions against usage of xargs ( while, like said, i for one sure can't say much about it).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.