Questions tagged [basename]
For questions pertaining to basename, a utility that returns the non-directory portion of a pathname.
42 questions
0
votes
1
answer
946
views
basename complains about missing operand using unshare
If I try to create namespaces, basename complains about missing operand:
sudo unshare --mount --ipc --uts --pid --fork --user /bin/bash
basename: missing operand
Try 'basename --help' for more ...
-2
votes
1
answer
133
views
How to trim directory from which output without basename?
For a shell script I need to call an executable by name, regardless of the path leading there; thus far I know this code reports the right name:
tmpprog=`which program`
prog=${tmpprog%%*/}
if $prog=&...
0
votes
1
answer
332
views
Basename detects an extra operand if I use it with find
I try to execute basename via find like this:
find ./test_folder -type f -exec basename {} +
But I get the following error:
basename: extra operand './test_folder/test/file.crt'
Why I get this ...
0
votes
2
answers
335
views
Basename in find -exec
I need use in find results full path and dir name.
This not work:
find ./1cv8 -maxdepth 1 -type d -wholename "./1cv8/*" -exec bash -c 'echo vrunner -src "{}" -o ./builds/"${...
0
votes
1
answer
989
views
Why basename don't work here [duplicate]
Why when I do this (I know, it's stupid) it returns the full path, not only the filename as expected?
ls -l | awk '{print $9}' | xargs -I% find ./my_dir -type f -name "%" -exec echo $(...
2
votes
1
answer
423
views
Why do I need to use the -I parameter in `compgen -G ... | xargs basename`?
I ran into a situation where I was piping the output of compgen -G to xargs basename and could not get it to work until I added the xargs -I parameter as seen below. Here is a script demonstrating ...
4
votes
3
answers
2k
views
find -exec command options with basename [duplicate]
I have the following JPEG files :
$ ls -l
-rw-r--r-- 1 user group 384065 janv. 21 12:10 CamScanner 01-10-2022 14.54.jpg
-rw-r--r-- 1 user group 200892 janv. 10 14:55 CamScanner 01-10-2022 14.55.jpg
-...
0
votes
4
answers
802
views
How can I output a txt file, that has part of filename followed by path of file for all files in a folder, one line per file?
I have the following files
/folder/abc1.txt.gz
/folder/abc2.txt.gz
/folder/abc3.txt.gz
I would like to make a txt file with the following
abc1 /folder/abc1.txt.gz
abc2 /folder/abc2.txt.gz
abc3 /...
0
votes
2
answers
254
views
Map over file tree, preserving structure
I have a file tree that looks like:
$ tree src
src
├── bible
│ ├── index.md
│ └── README.md
├── index.md
└── other.md
I want to render every Markdown file within this file tree to HTML via pandoc(...
3
votes
2
answers
616
views
How can I use basename with parallel?
I have files like this on a Linux system:
10S1_S5_L002_chrm.fasta SRR3184711_chrm.fasta SRR3987378_chrm.fasta SRR4029368_chrm.fasta SRR5204465_chrm.fasta SRR5997546_chrm.fasta
...
1
vote
1
answer
628
views
Bash: removing several patterns from file names
Normally, looping over the files I use basename to extract the name of the file as a separate variable:
# remove .pdb extension from filename in new variable and print name of the file without it
for ...
4
votes
1
answer
459
views
the command find not working with -name option in sh file [duplicate]
I am using the following command to retrieve the number of files which names contains sv or json in a given directory in a remote server:
nbs_files=`ssh -q -i ${sshkey} ${user}@${server} "find ${...
0
votes
3
answers
352
views
Filename from pathname excluding (unknown) extension
Having a pathname it is possible to extract its filename, excluding its apriori known extension, with basename:
$ pathname="/home/paulo/paulo.pdf"
$ printf "%s\n" "$(basename $pathname .pdf)"
paulo
...
0
votes
1
answer
149
views
basename execution on remote node
ssh ubuntu@$ip -n "aws s3 cp s3://bucket/$userlistlocation . --region eu-central-1 ; fbname=$(basename '$userlistlocation') ; echo "$fbname""
This above command is part of jenkins job.
...
3
votes
1
answer
2k
views
basename "$0" not working
I have this command:
base_name="$(basename "$0")";
and I am getting this error:
basename: illegal option -- b
usage: basename string [suffix]
basename [-a] [-s suffix] string [...]
...