Skip to content

Instantly share code, notes, and snippets.

@psenger
Last active February 11, 2024 22:41
Show Gist options
  • Select an option

  • Save psenger/9bbbf66deaf2dd85d919fe46241c0df4 to your computer and use it in GitHub Desktop.

Select an option

Save psenger/9bbbf66deaf2dd85d919fe46241c0df4 to your computer and use it in GitHub Desktop.
[Find files use basename extract the file name or extension ] #UNIX #find
## with this example, I can auto create the spec files based on functions
for item in `find ./src/controllers/external -type f`
do
FILENAME=`basename -s .js $item`
touch ./test/controllers/external/$FILENAME.spec.js
done
## ---------------------
## basename ./src/controllers/external/storeApi.js
## storeApi.js
## ---------------------
## basename -s .js ./src/controllers/external/storeApi.js
## storeApi
## ---------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment