Hi there,
How can i shorten this:
grep -ri "Password must meet complexity requirements" "$line" | sed 's/\t/<\/td><td>/' | sed 's/^.*:/<tr><td>/'| sed 's/$/<\/td><\/tr>/'
I am looking for a shorter alternative of sed. What I was trying to do is to change the string output format from
LPO/ULT0151_Password Policy.txt-Password must meet complexity requirements Enabled
to:
<tr><td>Password must meet complexity requirements</td><td>Enabled</td></tr>
sea
2
Why not make it workable first?
Unless $line
is a file, this wont work, remove "$line" and then try:
echo "$line" | grep ....
Regarding the sed question, sorry, looks good to me
hth
RudiC
3
The entire problem could be solved with e.g. awk
. Unfortunately there's no samples (in code tags) that we could work on.
---------- Post updated at 07:52 ---------- Previous update was at 07:44 ----------
Applying wild assumptions to your first post, try
awk '
/Password must meet complexity requirements/ {sub (/^.*-/,"")
$0="<tr><td>" $0 "</tr></td>"
sub ("\t","</td><td>")
}
1
' file
<tr><td>Password must meet complexity requirements</td><td>Enabled</tr></td>
Thread hijack removed to here.