![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Awk not working due to missing new line character at last line of file | pinnacle | Shell Programming and Scripting | 2 | 05-07-2009 10:51 PM |
| error while replacing a string by new line character in sed | millan | Shell Programming and Scripting | 8 | 04-28-2009 06:06 AM |
| Replacing a character string in a file | rjsha1 | Shell Programming and Scripting | 13 | 04-11-2009 02:07 PM |
| Replacing a character in a line | Usha Shastri | UNIX for Dummies Questions & Answers | 2 | 04-02-2009 03:08 AM |
| Replacing character in file with null value | HLee1981 | Shell Programming and Scripting | 18 | 07-18-2006 02:33 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Quote:
Per our forum rules, all users must write in English, use semi-formal or formal English language and style, and correct spelling errors. The reason for this is that most software and operating systems are written in English and these are software related technical forums. In addition, nearly 95% of all visitors to this site come here because they are referred by a search engine. In order for future searches on your post (with answers) to work well, you need to spell correctly! So, as a benefit and courtesy to current and future knowledge seekers, please be careful with your language, check your spelling and correct your spelling errors. You might receive a forum infraction if you don't pay attention to this. Also, do not write in cyberpunk or abbreviated chat style under any circumstances and do not use profanity. This is not a chat room, it is a formal knowledge base to serve you and everyone, of all ages and cultural backgrounds. Thanks! The UNIX and Linux Forums |
|
||||
|
sed 's/.$/z/'
this expression allow to replace last character by z -----Post Update----- try1 is your file cat try1 | while read line; do res=$(echo $line | awk -F "," '{print $NF}');if [ $res = "p" ];then var=$(echo $line | awk -F "," '{print $2}');echo $var;fi; done -----Post Update----- try1 is your file cat try1 | while read line; do res=$(echo $line | awk -F "," '{print $NF}');if [ $res = "p" ];then var=$(echo $line | awk -F "," '{print $2}');echo $var;fi; done |
|
||||
|
no need while loop, cat and those extra if/else and awk. Just one awk command can do it.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|