JAVA-20220 Added suffix -modules to aws-lambda, clojure, terraform, linux-bash
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
### Relevant Articles:
|
||||
|
||||
- [How to Use Command Line Arguments in a Bash Script](https://www.baeldung.com/linux/use-command-line-arguments-in-bash-script)
|
||||
- [Concatenate Two Strings to Build a Complete Path in Linux](https://www.baeldung.com/linux/concatenate-strings-to-build-path)
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
while getopts u:a:f: flag
|
||||
do
|
||||
case "${flag}"
|
||||
in
|
||||
u) username=${OPTARG};;
|
||||
a) age=${OPTARG};;
|
||||
f) fullname=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
echo "Username: $username";
|
||||
echo "Age: $age";
|
||||
echo "Full Name: $fullname";
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Username: $1";
|
||||
echo "Age: $2";
|
||||
echo "Full Name: $3";
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
i=1;
|
||||
for user in "$@"
|
||||
do
|
||||
echo "Username - $i: $user";
|
||||
i=$((i + 1));
|
||||
done
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
i=1;
|
||||
j=$#;
|
||||
while [ $i -le $j ]
|
||||
do
|
||||
echo "Username - $i: $1";
|
||||
i=$((i + 1));
|
||||
shift 1;
|
||||
done
|
||||
3
linux-bash-modules/functions/src/main/bash/README.md
Normal file
3
linux-bash-modules/functions/src/main/bash/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Relevant Articles
|
||||
|
||||
- [Bash Functions in Linux](https://www.baeldung.com/linux/bash-functions)
|
||||
208
linux-bash-modules/functions/src/main/bash/functions.sh
Executable file
208
linux-bash-modules/functions/src/main/bash/functions.sh
Executable file
@@ -0,0 +1,208 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Subsection 2.1
|
||||
simple_function() {
|
||||
for ((i=0;i<5;++i)) do
|
||||
echo -n " "$i" ";
|
||||
done
|
||||
}
|
||||
|
||||
function simple_function_no_parantheses {
|
||||
for ((i=0;i<5;++i)) do
|
||||
echo -n " "$i" ";
|
||||
done
|
||||
}
|
||||
|
||||
function simple_for_loop()
|
||||
for ((i=0;i<5;++i)) do
|
||||
echo -n " "$i" ";
|
||||
done
|
||||
|
||||
function simple_comparison()
|
||||
if [[ "$1" -lt 5 ]]; then
|
||||
echo "$1 is smaller than 5"
|
||||
else
|
||||
echo "$1 is greater than 5"
|
||||
fi
|
||||
|
||||
# Subsection 2.2
|
||||
function simple_inputs() {
|
||||
echo "This is the first argument [$1]"
|
||||
echo "This is the second argument [$2]"
|
||||
echo "Calling function with $# aruments"
|
||||
}
|
||||
|
||||
# Subsection 2.3
|
||||
global_sum=0
|
||||
function global_sum_outputs() {
|
||||
global_sum=$(($1+$2))
|
||||
}
|
||||
|
||||
function cs_sum_outputs() {
|
||||
sum=$(($1+$2))
|
||||
echo $sum
|
||||
}
|
||||
|
||||
# Subsection 2.4
|
||||
function arg_ref_sum_outputs() {
|
||||
declare -n sum_ref=$3
|
||||
sum_ref=$(($1+$2))
|
||||
}
|
||||
|
||||
# Subsection 3.1
|
||||
variable="baeldung"
|
||||
function variable_scope2() {
|
||||
echo "Variable inside function variable_scope2: [$variable]"
|
||||
local variable="ipsum"
|
||||
}
|
||||
|
||||
function variable_scope() {
|
||||
local variable="lorem"
|
||||
echo "Variable inside function variable_scope: [$variable]"
|
||||
variable_scope2
|
||||
}
|
||||
|
||||
# Subsection 3.2
|
||||
subshell_sum=0
|
||||
function simple_subshell_sum() (
|
||||
subshell_sum=$(($1+$2))
|
||||
echo "Value of sum in function with global variables: [$subshell_sum]"
|
||||
)
|
||||
|
||||
function simple_subshell_ref_sum() (
|
||||
declare -n sum_ref=$3
|
||||
sum_ref=$(($1+$2))
|
||||
echo "Value of sum in function with ref arguments: [$sum_ref]"
|
||||
)
|
||||
|
||||
# Subsection 3.3
|
||||
function redirection_in() {
|
||||
while read input;
|
||||
do
|
||||
echo "$input"
|
||||
done
|
||||
} < infile
|
||||
|
||||
function redirection_in_ps() {
|
||||
read
|
||||
while read -a input;
|
||||
do
|
||||
echo "User[${input[2]}]->File[${input[8]}]"
|
||||
done
|
||||
} < <(ls -ll /)
|
||||
|
||||
function redirection_out_ps() {
|
||||
declare -a output=("baeldung" "lorem" "ipsum" "caracg")
|
||||
for element in "${output[@]}"
|
||||
do
|
||||
echo "$element"
|
||||
done
|
||||
} > >(grep "g")
|
||||
|
||||
function redirection_out() {
|
||||
declare -a output=("baeldung" "lorem" "ipsum")
|
||||
for element in "${output[@]}"
|
||||
do
|
||||
echo "$element"
|
||||
done
|
||||
} > outfile
|
||||
|
||||
# Subsection 3.4
|
||||
function fibonnaci_recursion() {
|
||||
argument=$1
|
||||
if [[ "$argument" -eq 0 ]] || [[ "$argument" -eq 1 ]]; then
|
||||
echo $argument
|
||||
else
|
||||
first=$(fibonnaci_recursion $(($argument-1)))
|
||||
second=$(fibonnaci_recursion $(($argument-2)))
|
||||
echo $(( $first + $second ))
|
||||
fi
|
||||
}
|
||||
|
||||
# main menu entry point
|
||||
echo "****Functions samples menu*****"
|
||||
PS3="Your choice (1,2,3 etc.):"
|
||||
options=("function_definitions" "function_input_args" "function_outputs" \
|
||||
"function_variables" "function_subshells" "function_redirections" \
|
||||
"function_recursion" "quit")
|
||||
select option in "${options[@]}"
|
||||
do
|
||||
case $option in
|
||||
"function_definitions")
|
||||
echo -e "\n"
|
||||
echo "**Different ways to define a function**"
|
||||
echo -e "No function keyword:"
|
||||
simple_function
|
||||
echo -e "\nNo function parantheses:"
|
||||
simple_function_no_parantheses
|
||||
echo -e "\nOmitting curly braces:"
|
||||
simple_for_loop
|
||||
echo -e "\n"
|
||||
;;
|
||||
"function_input_args")
|
||||
echo -e "\n"
|
||||
echo "**Passing inputs to a function**"
|
||||
simple_inputs lorem ipsum
|
||||
echo -e "\n"
|
||||
;;
|
||||
"function_outputs")
|
||||
echo -e "\n"
|
||||
echo "**Getting outputs from a function**"
|
||||
global_sum_outputs 1 2
|
||||
echo -e ">1+2 using global variables: [$global_sum]"
|
||||
cs_sum=$(cs_sum_outputs 1 2)
|
||||
echo -e ">1+2 using command substitution: [$cs_sum]"
|
||||
arg_ref_sum_outputs 1 2 arg_ref_sum
|
||||
echo -e ">1+2 using argument references: [$arg_ref_sum]"
|
||||
echo -e "\n"
|
||||
;;
|
||||
"function_variables")
|
||||
echo -e "\n"
|
||||
echo "**Overriding variable scopes**"
|
||||
echo "Global value of variable: [$variable]"
|
||||
variable_scope
|
||||
echo -e "\n"
|
||||
;;
|
||||
"function_subshells")
|
||||
echo -e "\n"
|
||||
echo "**Running function in subshell**"
|
||||
echo "Global value of sum: [$subshell_sum]"
|
||||
simple_subshell_sum 1 2
|
||||
echo "Value of sum after subshell function with \
|
||||
global variables: [$subshell_sum]"
|
||||
subshell_sum_arg_ref=0
|
||||
simple_subshell_ref_sum 1 2 subshell_sum_arg_ref
|
||||
echo "Value of sum after subshell function with \
|
||||
ref arguments: [$subshell_sum_arg_ref]"
|
||||
echo -e "\n"
|
||||
;;
|
||||
"function_redirections")
|
||||
echo -e "\n"
|
||||
echo "**Function redirections**"
|
||||
echo -e ">Function input redirection from file:"
|
||||
redirection_in
|
||||
echo -e ">Function input redirection from command:"
|
||||
redirection_in_ps
|
||||
echo -e ">Function output redirection to file:"
|
||||
redirection_out
|
||||
cat outfile
|
||||
echo -e ">Function output redirection to command:"
|
||||
red_ps=$(redirection_out_ps)
|
||||
echo "$red_ps"
|
||||
echo -e "\n"
|
||||
;;
|
||||
"function_recursion")
|
||||
echo -e "\n"
|
||||
echo "**Function recursion**"
|
||||
fibo_res1=$(fibonnaci_recursion 7)
|
||||
echo "The 7th Fibonnaci number: [$fibo_res1]"
|
||||
fibo_res2=$(fibonnaci_recursion 15)
|
||||
echo "The 15th Fibonnaci number: [$fibo_res2]"
|
||||
echo -e "\n"
|
||||
;;
|
||||
"quit")
|
||||
break
|
||||
;;
|
||||
*) echo "Invalid option";;
|
||||
esac
|
||||
done
|
||||
3
linux-bash-modules/functions/src/main/bash/infile
Normal file
3
linux-bash-modules/functions/src/main/bash/infile
Normal file
@@ -0,0 +1,3 @@
|
||||
Honda Insight 2010
|
||||
Honda Element 2006
|
||||
Chevrolet Avalanche 2002
|
||||
2
linux-bash-modules/json/README.md
Normal file
2
linux-bash-modules/json/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
### Relevant Articles:
|
||||
- [Guide to Linux jq Command for JSON Processing](https://www.baeldung.com/linux/jq-command-json)
|
||||
1
linux-bash-modules/json/src/main/bash/fruit.json
Normal file
1
linux-bash-modules/json/src/main/bash/fruit.json
Normal file
@@ -0,0 +1 @@
|
||||
{"fruit":{"name":"apple","color":"green","price":1.20}}
|
||||
17
linux-bash-modules/json/src/main/bash/fruits.json
Normal file
17
linux-bash-modules/json/src/main/bash/fruits.json
Normal file
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"name": "apple",
|
||||
"color": "green",
|
||||
"price": 1.2
|
||||
},
|
||||
{
|
||||
"name": "banana",
|
||||
"color": "yellow",
|
||||
"price": 0.5
|
||||
},
|
||||
{
|
||||
"name": "kiwi",
|
||||
"color": "green",
|
||||
"price": 1.25
|
||||
}
|
||||
]
|
||||
56
linux-bash-modules/json/src/main/bash/jq.sh
Executable file
56
linux-bash-modules/json/src/main/bash/jq.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
|
||||
#3.1. Beautify JSON
|
||||
echo '{"fruit":{"name":"apple","color":"green","price":1.20}}' | jq '.'
|
||||
jq '.' fruit.json
|
||||
curl http://api.open-notify.org/iss-now.json | jq '.'
|
||||
|
||||
#3.2. Accessing Properties
|
||||
jq '.fruit' fruit.json
|
||||
jq '.fruit.color' fruit.json
|
||||
jq '.fruit.color,.fruit.price' fruit.json
|
||||
echo '{ "with space": "hello" }' | jq '."with space"'
|
||||
|
||||
#4.1. Iteration
|
||||
echo '["x","y","z"]' | jq '.[]'
|
||||
jq '.[] | .name' fruits.json
|
||||
jq '.[].name' fruits.json
|
||||
|
||||
#4.2. Accessing By Index
|
||||
jq '.[1].price' fruits.json
|
||||
|
||||
#4.3. Slicing
|
||||
echo '[1,2,3,4,5,6,7,8,9,10]' | jq '.[6:9]'
|
||||
echo '[1,2,3,4,5,6,7,8,9,10]' | jq '.[:6]' | jq '.[-2:]'
|
||||
|
||||
#5.1. Getting Keys
|
||||
jq '.fruit | keys' fruit.json
|
||||
|
||||
#5.2. Returning the Length
|
||||
jq '.fruit | length' fruit.json
|
||||
jq '.fruit.name | length' fruit.json
|
||||
|
||||
#5.3. Mapping Values
|
||||
jq 'map(has("name"))' fruits.json
|
||||
jq 'map(.price+2)' fruits.json
|
||||
|
||||
#5.4. Min and Max
|
||||
jq '[.[].price] | min' fruits.json
|
||||
jq '[.[].price] | max' fruits.json
|
||||
|
||||
#5.5. Selecting Values
|
||||
jq '.[] | select(.price>0.5)' fruits.json
|
||||
jq '.[] | select(.color=="yellow")' fruits.json
|
||||
jq '.[] | select(.color=="yellow" and .price>=0.5)' fruits.json
|
||||
|
||||
#5.6. Support For RegEx
|
||||
jq '.[] | select(.name|test("^a.")) | .price' fruits.json
|
||||
|
||||
#5.7. Find Unique Values
|
||||
jq 'map(.color) | unique' fruits.json
|
||||
|
||||
#5.8. Deleting Keys From JSON
|
||||
jq 'del(.fruit.name)' fruit.json
|
||||
|
||||
# 6. Transforming
|
||||
jq '.query.pages | [.[] | map(.) | .[] | {page_title: .title, page_description: .extract}]' wikipedia.json
|
||||
22
linux-bash-modules/json/src/main/bash/wikipedia.json
Normal file
22
linux-bash-modules/json/src/main/bash/wikipedia.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"query": {
|
||||
"pages": [
|
||||
{
|
||||
"21721040": {
|
||||
"pageid": 21721040,
|
||||
"ns": 0,
|
||||
"title": "Stack Overflow",
|
||||
"extract": "Some interesting text about Stack Overflow"
|
||||
}
|
||||
},
|
||||
{
|
||||
"21721041": {
|
||||
"pageid": 21721041,
|
||||
"ns": 0,
|
||||
"title": "Baeldung",
|
||||
"extract": "A great place to learn about Java"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
3
linux-bash-modules/loops/README.md
Normal file
3
linux-bash-modules/loops/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Relevant Articles:
|
||||
|
||||
- [Linux Commands – Looping Through Directories](https://www.baeldung.com/linux/loop-directories)
|
||||
9
linux-bash-modules/loops/src/main/bash/find_directories.sh
Executable file
9
linux-bash-modules/loops/src/main/bash/find_directories.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
find . -maxdepth 1 -mindepth 1 -type d -printf '%f\n'
|
||||
|
||||
find . -maxdepth 1 -mindepth 1 -type d | while read dir; do
|
||||
echo "$dir"
|
||||
done
|
||||
|
||||
find . -maxdepth 1 -type d -exec echo {} \;
|
||||
11
linux-bash-modules/loops/src/main/bash/loop_directories.sh
Executable file
11
linux-bash-modules/loops/src/main/bash/loop_directories.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
for dir in */; do
|
||||
echo "$dir"
|
||||
done
|
||||
|
||||
for file in *; do
|
||||
if [ -d "$file" ]; then
|
||||
echo "$file"
|
||||
fi
|
||||
done
|
||||
3
linux-bash-modules/read/README.md
Normal file
3
linux-bash-modules/read/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Relevant Articles:
|
||||
|
||||
- [Guide to the Linux read Command](https://www.baeldung.com/linux/read-command)
|
||||
1
linux-bash-modules/read/src/main/bash/file.csv
Normal file
1
linux-bash-modules/read/src/main/bash/file.csv
Normal file
@@ -0,0 +1 @@
|
||||
car,car model,car year,car vin;Mercury,Grand Marquis,2000,2G61S5S33F9986032;Mitsubishi,Truck,1995,SCFFDABE1CG137362;Ford,Mustang,1968,2G4WS55J351278031;Ford,Crown Victoria,1996,4T1BK1EB8EU586249;GMC,Envoy,2004,WVGEF9BP3FD720618;
|
||||
|
122
linux-bash-modules/read/src/main/bash/read_inputs.sh
Executable file
122
linux-bash-modules/read/src/main/bash/read_inputs.sh
Executable file
@@ -0,0 +1,122 @@
|
||||
#!/bin/bash
|
||||
|
||||
# section 2.1
|
||||
default_read(){
|
||||
read input1 input2 input3
|
||||
echo "[$input1] [$input2] [$input3]"
|
||||
}
|
||||
|
||||
# section 2.2
|
||||
custom_ifs_no_array(){
|
||||
OLDIFS=$IFS
|
||||
IFS=";"
|
||||
read input1 input2 input3
|
||||
echo "[$input1] [$input2] [$input3]"
|
||||
# restore default IFS after we're finished so current shell behaves like before
|
||||
IFS=$OLDIFS
|
||||
}
|
||||
|
||||
# Section 2.3
|
||||
prompt_read_password(){
|
||||
prompt="You shall not pass:"
|
||||
read -p "$prompt" -s input
|
||||
echo -e "\ninput password [$input]"
|
||||
}
|
||||
|
||||
array_read(){
|
||||
declare -a input_array
|
||||
text="baeldung is a cool tech site"
|
||||
read -e -i "$text" -a input_array
|
||||
for input in ${input_array[@]}
|
||||
do
|
||||
echo " word [$input]"
|
||||
done
|
||||
}
|
||||
|
||||
# section 3.1
|
||||
file_read(){
|
||||
exec {file_descriptor}<"./file.csv"
|
||||
declare -a input_array
|
||||
delimiter=";"
|
||||
while IFS="," read -a input_array -d $delimiter -u $file_descriptor
|
||||
do
|
||||
echo "${input_array[0]},${input_array[2]}"
|
||||
done
|
||||
exec {file_descriptor}>&-
|
||||
}
|
||||
|
||||
# section 3.2
|
||||
command_pipe(){
|
||||
ls -ll / | { declare -a input
|
||||
read
|
||||
while read -a input;
|
||||
do
|
||||
echo "${input[0]} ${input[8]}"
|
||||
done }
|
||||
}
|
||||
|
||||
# section 3.3
|
||||
timeout_input_read(){
|
||||
prompt="You shall not pass:"
|
||||
read -p "$prompt" -s -r -t 5 input
|
||||
if [ -z "$input" ]; then
|
||||
echo -e "\ntimeout occured!"
|
||||
else
|
||||
echo -e "\ninput word [$input]"
|
||||
fi
|
||||
}
|
||||
|
||||
exactly_n_read(){
|
||||
prompt="Reading exactly 11 chars:"
|
||||
read -p "$prompt" -N 11 -t 5 input1 input2
|
||||
echo -e "\ninput word1 [$input1]"
|
||||
echo "input word2 [$input2]"
|
||||
}
|
||||
|
||||
# main menu entry point
|
||||
echo "****Read command samples menu*****"
|
||||
PS3="Your choice (1,2,3 etc.):"
|
||||
options=("default_read" "custom_ifs_no_array" "prompt_read_password" \
|
||||
"array_read" "file_read" "command_pipe" "timeout_input_read" \
|
||||
"exactly_n_read" "quit")
|
||||
select option in "${options[@]}"
|
||||
do
|
||||
case $option in
|
||||
"default_read")
|
||||
echo "Enter something separated by spaces"
|
||||
default_read
|
||||
;;
|
||||
"custom_ifs_no_array")
|
||||
echo "Enter something separated by ;"
|
||||
custom_ifs_no_array
|
||||
;;
|
||||
"prompt_read_password")
|
||||
echo "Enter an invisible password after the prompt"
|
||||
prompt_read_password
|
||||
;;
|
||||
"array_read")
|
||||
echo "Enter something else or just return"
|
||||
array_read
|
||||
;;
|
||||
"file_read")
|
||||
echo "Reading from one liner csv file"
|
||||
file_read
|
||||
;;
|
||||
"command_pipe")
|
||||
echo "Listing files and access rights from /"
|
||||
command_pipe
|
||||
;;
|
||||
"timeout_input_read")
|
||||
echo "Enter something in 5 seconds or less"
|
||||
timeout_input_read
|
||||
;;
|
||||
"exactly_n_read")
|
||||
echo "Enter at least 11 characters or wait 5 seconds"
|
||||
exactly_n_read
|
||||
;;
|
||||
"quit")
|
||||
break
|
||||
;;
|
||||
*) echo "Invalid option";;
|
||||
esac
|
||||
done
|
||||
3
linux-bash-modules/text/README.md
Normal file
3
linux-bash-modules/text/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Relevant Articles:
|
||||
|
||||
- [Linux Commands for Appending Multiple Lines to a File](https://www.baeldung.com/linux/appending-multiple-lines-to-file2)
|
||||
29
linux-bash-modules/text/src/main/bash/append_multiple_lines.sh
Executable file
29
linux-bash-modules/text/src/main/bash/append_multiple_lines.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
# echo per line
|
||||
echo Lorem ipsum dolor sit amet, consectetur adipiscing elit, >> echo-per-line.txt
|
||||
echo sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. >> echo-per-line.txt
|
||||
|
||||
# echo with escaped newline
|
||||
echo -e Lorem ipsum dolor sit amet, consectetur adipiscing elit,\\nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua. >> echo-escaped-newline.txt
|
||||
|
||||
# echo with double quoted string
|
||||
echo -e "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua." >> echo-double-quoted.txt
|
||||
|
||||
# printf instead of echo
|
||||
printf "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua." >> printf.txt
|
||||
|
||||
# printf using format string
|
||||
printf "%s\n%s" "Lorem ipsum dolor sit amet, consectetur adipiscing elit," "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." >> printf-format.txt
|
||||
|
||||
# cat
|
||||
cat << EOF >> cat.txt
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
EOF
|
||||
|
||||
# tee
|
||||
tee -a tee.txt << EOF
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
EOF
|
||||
|
||||
19
linux-bash-modules/text/src/main/bash/remove_characters.sh
Executable file
19
linux-bash-modules/text/src/main/bash/remove_characters.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
my_var="Hola Mundo"
|
||||
echo ${my_var}
|
||||
|
||||
my_filename="interesting-text-file.txt"
|
||||
echo ${my_filename:0:21}
|
||||
|
||||
echo ${my_filename%.*}
|
||||
|
||||
complicated_filename="hello-world.tar.gz"
|
||||
echo ${complicated_filename%%.*}
|
||||
|
||||
echo ${my_filename/.*/}
|
||||
|
||||
echo 'interesting-text-file.txt' | sed 's/.txt*//'
|
||||
|
||||
echo 'interesting-text-file.txt' | cut -f1 -d"."
|
||||
echo ${complicated_filename} | cut -f1 -d"."
|
||||
Reference in New Issue
Block a user