Relative Content

Tag Archive for linuxbashshell

Bash named pipe blocking

For some reason, this bash script never gets to echo "after cat", but does get past echo "before cat".

Setting environment variable from command stored in array

I have a list of commands which I dynamically read in my script, each command is stored in a line. Some lines contain commands like the following
line="env_var="xxx" myexe -flag1 -flag2
I’m trying to run all lines (including these) from my script.

what can i use instead read filepath

Function to Edit an existing file
edit_existing_file() {
echo “Enter the full path or name of the file to edit:”
read filepath
if [ -f “$filepath” ]; then
# Display file contents with line numbers
nl “$filepath”
cat > “$filepath.tmp” # Create temporary file to store new text
mv “$filepath.tmp” “$filepath” # Replace original file with the one containing new text
echo “File edited.”
else
echo “File not found.”
fi
}