Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash get file name

# Basic syntax:
basename $YOURFILE

# Example usage:
YOURFILE="/path/to/your_file.txt"
basename $YOURFILE
--> your_file.txt

# Note, to remove a specified suffix from the file name, add it at the end like:
basename $YOURFILE .txt
--> your_file

# Note, to run basename in a bash script and assign the output to a variable,
# use the following syntax:
FILENAME="$(basename -- $YOURFILE)"
Comment

bash find file by name

find . -name 'mystring*'
Comment

sh get filename

# ------------- SCRIPT ------------- #

#!/bin/bash

echo
echo "# arguments called with ---->  ${@}     "
echo "# $1 ---------------------->  $1       "
echo "# $2 ---------------------->  $2       "
echo "# path to me --------------->  ${0}     "
echo "# parent path -------------->  ${0%/*}  "
echo "# my name ------------------>  ${0##*/} "
echo
exit

# ------------- CALLED ------------- #

# Notice on the next line, the first argument is called within double, 
# and single quotes, since it contains two words

$  /misc/shell_scripts/check_root/show_parms.sh "'hello there'" "'william'"

# ------------- RESULTS ------------- #

# arguments called with --->  'hello there' 'william'
# $1 ---------------------->  'hello there'
# $2 ---------------------->  'william'
# path to me -------------->  /misc/shell_scripts/check_root/show_parms.sh
# parent path ------------->  /misc/shell_scripts/check_root
# my name ----------------->  show_parms.sh

# ------------- END ------------- #
Comment

PREVIOUS NEXT
Code Example
Shell :: how to check git changes before commit 
Shell :: vs code always says rebasing git 
Shell :: uninstall service cmd 
Shell :: Fatal error in launcher: 
Shell :: install k3s without traefik 
Shell :: vs code set ubuntu wsl as default terminal 
Shell :: uninstall redis ubuntu terminal 
Shell :: zsh: command not found: nvm 
Shell :: gnu vs unix 
Shell :: nodemon command not found 
Shell :: pom extract version linux 
Shell :: mongodb view users 
Shell :: sudo apt-get --purge remove 
Shell :: how to completely remove blender from ubuntu 
Shell :: delete ip by ufw 
Shell :: read password bash 
Shell :: linux how to open code detached 
Shell :: Build Blender git commands 
Shell :: delete old version of snaps 
Shell :: install svelte 
Shell :: branch list in git 
Shell :: docker remove all images with name <none 
Shell :: increase volume from terminal 
Shell :: Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs 
Shell :: github resolve issue large file 
Shell :: command not found: gradlew.bat 
Shell :: How To Uninstall JDK From Linux 
Shell :: command to check recent commit 
Shell :: adonis create app 
Shell :: how to commit single / multiple file in git 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =