BASH LEER ARCHIVO Y SALIDA
function_name () {
echo "Parameter #1 is $1"
}
Brave Badger
function_name () {
echo "Parameter #1 is $1"
}
$/> npm init -y
$ VAR='/home/pax/file.c'
$ DIR="$(dirname "${VAR}")" ; FILE="$(basename "${VAR}")"
$ echo "[${DIR}] [${FILE}]"
[/home/pax] [file.c]
APP_ROOT=$(dirname $(dirname $(readlink -fm $0)))
#!/bin/bash
value=$(pwd)
regex='.*\/([a-zA-Z0-9\._]*)\/([a-zA-Z0-9\._]*)$'
echo You are here: $value
echo The folder is: ${value##*/}
[[ $value =~ $regex ]]
echo Parent folder: ${BASH_REMATCH[1]}
#!/bin/bash
firstString="I love Suzi and Marry"
secondString="Sara"
echo "${firstString/Suzi/"$secondString"}"
# prints 'I love Sara and Marry'
#/usr/bin/env bash
DIRECTORY="/home/user/example/foo/bar"
BASE_DIRECTORY=$(echo "$DIRECTORY" | cut -d "/" -f2)
echo "#$BASE_DIRECTORY#";
for each in "${alpha[@]}"
do
echo "$each"
done