Unix command to remove dot at end of each line in file.
Sample rec in file
11234567 0.
23456789 5569.
34567810 1.
10162056 0.
$1 means an input argument and -z means non-defined or empty. You're testing whether an input argument to the script was defined when running the script. Follow this answer to receive notifications.
The operator "%" will try to remove the shortest text matching the pattern, while "%%" tries to do it with the longest text matching.
To remove the last n characters of a string, we can use the parameter expansion syntax ${str::-n} in the Bash shell. -n is the number of characters we need to remove from the end of a string.
The most common way is to use the echo command. However, the printf command also works fine. Using the backslash character for newline “\n” is the conventional way.
Just use sed
:
sed 's/\.$//' yourfile
.
using \
. $
to only remove it from the end. -i
option of sed
. sed -e 's/\.$//'
done. (padding to make answer long enough. grumble)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With