I need help in a specific problem.
I have a relative Path in a Flutter project, and I need to get the file name (without .dart extension) and adding two asterisks before that.
I need to create a shell script to execute in my PC like this:
EJ.
- Convert this
prueba/de/una/ruta/main.dart
- Into this
prueba/de/una/ruta/**.dart
----
Actually I'm trying something like get the file name and replace it with this code but is not working
echo "test/holas.dart" | sed "/(?<=\/)[^\/] (?=\.dart)/g";
Actual output:
test/holas.dart
Expected output:
holas
If someone know something to get the expected output or how to build the entire Script file i appreciate help
CodePudding user response:
Using sed
$ echo 'prueba/de/una/ruta/main.dart' | sed -E 's~(.*/)[^.]*~\1**~'
prueba/de/una/ruta/**.dart
$ echo "test/holas.dart" | sed -E 's~.*/|\..*~~g'
holas