Hello from Arizona
by LSnodgrass from LinuxQuestions.org on (#588C9)
Very interested in Embedded Linux, config management, regular expressions, command line 'pipeline' puzzles and solutions.
Puzzles like this:
# For each text file in this directory,
# replace the row (line) in the file beginning with <path//>
# with "<path//>" and the fully qualified pathname
# something like
# <path//> /c/Users/john.smith/Documents/glossary.txt
#
# And better yet, perform a regex on the 'realpath' value, changing it into a
# Windows path like this:
# <path//> C:/Users/john.smith/Documents/glossary.txt
#
for filename in $(find . -type f -depth 1 -iname '*.txt' | xargs realpath)
do
sed -i.bak -n -e '/<path\/\/>/ {s/<path\/\/>.*$/<path\/\/> ${filename}/ }' ${filename}
echo Done ${filename}
done
# Again, this is just an introduction, not a legitimate post for assistance.
# And no, the bash + sed script above doesn't work yet.
# It's "the kind of" problems I am interested in solving from the command line
# as opposed to other solutions like writing a custom C, C++, C#, Python, Perl, PowerShell
# script.
#
A quote I really like:
"The best way to learn something is to try explaining it to the computer."


Puzzles like this:
# For each text file in this directory,
# replace the row (line) in the file beginning with <path//>
# with "<path//>" and the fully qualified pathname
# something like
# <path//> /c/Users/john.smith/Documents/glossary.txt
#
# And better yet, perform a regex on the 'realpath' value, changing it into a
# Windows path like this:
# <path//> C:/Users/john.smith/Documents/glossary.txt
#
for filename in $(find . -type f -depth 1 -iname '*.txt' | xargs realpath)
do
sed -i.bak -n -e '/<path\/\/>/ {s/<path\/\/>.*$/<path\/\/> ${filename}/ }' ${filename}
echo Done ${filename}
done
# Again, this is just an introduction, not a legitimate post for assistance.
# And no, the bash + sed script above doesn't work yet.
# It's "the kind of" problems I am interested in solving from the command line
# as opposed to other solutions like writing a custom C, C++, C#, Python, Perl, PowerShell
# script.
#
A quote I really like:
"The best way to learn something is to try explaining it to the computer."