Jan 8, 2004 #1 cantubas Programmer Jan 8, 2004 45 FR i wants to seach text and when i underline it in the same file. i try with tr and with sed but i can't do it it is possible?
i wants to seach text and when i underline it in the same file. i try with tr and with sed but i can't do it it is possible?
Jan 9, 2004 #2 aigles Technical User Sep 20, 2001 464 FR What kind of undurline do you want ? For printing ? TEXT\b\b\b\b____ For displaying on screen ? \033[4mTEXT\033[0m Other type ? Jean Pierre. Upvote 0 Downvote
What kind of undurline do you want ? For printing ? TEXT\b\b\b\b____ For displaying on screen ? \033[4mTEXT\033[0m Other type ? Jean Pierre.
Jan 9, 2004 Thread starter #3 cantubas Programmer Jan 8, 2004 45 FR on screen but on terminal HP. that why i try with the function tput but sed and tr don't accept a funtion into a string. Upvote 0 Downvote
on screen but on terminal HP. that why i try with the function tput but sed and tr don't accept a funtion into a string.
Jan 9, 2004 #4 Ygor Programmer Feb 21, 2003 623 GB Try.. [tt] STRING='search text' FILENAME='yourfile.txt' SU=`tput smul` EU=`tput rmul` sed -n "s/\($STRING\)/$SU\1$EU/p" $FILENAME Upvote 0 Downvote
Try.. [tt] STRING='search text' FILENAME='yourfile.txt' SU=`tput smul` EU=`tput rmul` sed -n "s/\($STRING\)/$SU\1$EU/p" $FILENAME
Jan 9, 2004 #5 aigles Technical User Sep 20, 2001 464 FR Solution 1 using sed : [tt] --- underline.sh --- [ $# -eq 0 ] && exit SedFile=/tmp/underline.sed.$$ Text="$1" shift cat <<EOF >$SedFile s/\($Text\)/$(tput sgr 0 1)\1$(tput sgr 0 0)/g EOF sed -f $SedFile $* rm -f $SedFile -------------------- underline.sh searched_text [ files... ] [/tt][/i] Solution 2 using awk : [tt] --- underline.awk --- BEGIN { if (ARGC < 2) exit; "tput sgr 0 1" | getline Under_On ; "tput sgr 0 0" | getline Under_Off ; Text = ARGV[1] ; ARGV[1] = ""; if (ARGC == 2) ARGV[ARGC++] = "-"; Underlined = Under_On Text Under_Off; } { gsub(Text,Underlined); print $0; } --------------------- awk -f underline.awk searched_text [ files... ] [/tt] Jean Pierre. Upvote 0 Downvote
Solution 1 using sed : [tt] --- underline.sh --- [ $# -eq 0 ] && exit SedFile=/tmp/underline.sed.$$ Text="$1" shift cat <<EOF >$SedFile s/\($Text\)/$(tput sgr 0 1)\1$(tput sgr 0 0)/g EOF sed -f $SedFile $* rm -f $SedFile -------------------- underline.sh searched_text [ files... ] [/tt][/i] Solution 2 using awk : [tt] --- underline.awk --- BEGIN { if (ARGC < 2) exit; "tput sgr 0 1" | getline Under_On ; "tput sgr 0 0" | getline Under_Off ; Text = ARGV[1] ; ARGV[1] = ""; if (ARGC == 2) ARGV[ARGC++] = "-"; Underlined = Under_On Text Under_Off; } { gsub(Text,Underlined); print $0; } --------------------- awk -f underline.awk searched_text [ files... ] [/tt] Jean Pierre.
Jan 9, 2004 #6 PHV MIS Nov 8, 2002 53,708 FR Try something like this: Code: smul=`tput smul`; sgr0=`tput sgr0` str="YourSearchedString" awk '{gsub(/'"$str"'/,"'"${smul}${str}${sgr0}"'");print }' /path/to/file Hope This Help PH. Upvote 0 Downvote
Try something like this: Code: smul=`tput smul`; sgr0=`tput sgr0` str="YourSearchedString" awk '{gsub(/'"$str"'/,"'"${smul}${str}${sgr0}"'");print }' /path/to/file Hope This Help PH.