cat file.txt
fvnuiehuewf
ruevhxncvkjrh
zxjvurhfuwe
jkhvBEGINvfnvf
ijrgioe
Trying to delete a line that has the pattern "BEGIN"
cat sedtest
filename=file.txt
pattern=BEGIN
sed "/^$pattern/d" "$filename"
cat file.txt
fvnuiehuewf
ruevhxncvkjrh
zxjvurhfuwe
jkhvBEGINvfnvf
ijrgioe
Trying to delete a line that has the pattern "BEGIN"
cat sedtest
filename=file.txt
pattern=BEGIN
sed "/^$pattern/d" "$filename"
sed "/$pattern/d" file
Thank you.
How can I save this output in a variable and print that result (from variable)?
# VAR=$(sed "/$pattern/d" file)
# echo $VAR
fvnuiehuewf ruevhxncvkjrh zxjvurhfuwe ijrgioe
# echo "$VAR"
fvnuiehuewf
ruevhxncvkjrh
zxjvurhfuwe
ijrgioe
How to print the result using sed and pipe "|" ?
#!/usr/bin/bash
filename=file.txt
pattern=BEGIN
cat "$filename" | sed "/$pattern/d"
How to change the contents of that file?That means deleting the line with "BEGIN" pattern from the file?
sed -i "/$pattern/d" file
I think it is not possible to do this without creating a temporary file.
Is there a way to doo this using awk?
S
---------- Post updated at 02:13 PM ---------- Previous update was at 02:12 PM ----------
sed -i doesn't work on my UNIX (solaris 5.10)
Thank you.
Got this here: