The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
To remove new line character shihabvk UNIX for Advanced & Expert Users 7 06-18-2009 07:44 AM
Vi single character change Brett Taylor Shell Programming and Scripting 6 08-30-2006 02:07 PM
remove single-line comment Icy002 High Level Programming 3 04-09-2006 08:30 AM
reading a single character in C alodha High Level Programming 3 01-28-2005 06:22 AM
Remove Last Character of Line danhodges99 Shell Programming and Scripting 4 05-21-2003 09:30 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-02-2007
Iz3k34l Iz3k34l is offline
Registered User
  
 

Join Date: Jul 2007
Location: Texas
Posts: 3
Unhappy Trying to remove single character from a line

Here is a sample code

grep '903' -i user.txt | tail -2 | awk '{print $2}' | sed 's/B//g'

the input file has data as such
903-xxx-xxxxB
903-xxx-xxxxB
It is a dialer file i want to remove the "B"


any help thanks
  #2 (permalink)  
Old 07-03-2007
xander xander is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 25
this code is already working

can you please explain what do you wanna remove

because your code
Quote:
grep '903' -i user.txt | tail -2 | awk '{print $2}' | sed 's/B//g'
is alrady working to remove 'B'
so is there anything else you want to remove
  #3 (permalink)  
Old 07-03-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,422
Quote:
Originally Posted by Iz3k34l View Post
Here is a sample code

grep '903' -i user.txt | tail -2 | awk '{print $2}' | sed 's/B//g'

the input file has data as such
903-xxx-xxxxB
903-xxx-xxxxB
It is a dialer file i want to remove the "B"


any help thanks
you will not get results from the "awk" part, because $2 will be nothing. the field separator is wrong. You can also do it all in awk
Code:
awk '/^903/{gsub(/B$/,"")}{print}' user.txt
  #4 (permalink)  
Old 07-03-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Quote:
Originally Posted by Iz3k34l View Post
Here is a sample code

grep '903' -i user.txt | tail -2 | awk '{print $2}' | sed 's/B//g'

the input file has data as such
903-xxx-xxxxB
903-xxx-xxxxB
It is a dialer file i want to remove the "B"


any help thanks
Code:
sed -e "s/\(903.*\)B$/\1/g" user.txt
  #5 (permalink)  
Old 07-03-2007
Iz3k34l Iz3k34l is offline
Registered User
  
 

Join Date: Jul 2007
Location: Texas
Posts: 3
character removal

xander, yes the code works but it doesnt terminate if locks up and it also doesnt change the source file. that is what i want to accomplish.here is the part of the file as it apears.


RPNUM: 903-310-7076B

i want to remove the 'B' so the dialer can call the num

my way will remove the num from the output but not the source file
also it freezes.

the other examples didnt seem to works

thanks everybody
  #6 (permalink)  
Old 07-07-2007
Iz3k34l Iz3k34l is offline
Registered User
  
 

Join Date: Jul 2007
Location: Texas
Posts: 3
update on Ghostdog usage

thanks for your help.

some of the problems i was having was removing the B from the DOB line. along with the B from the Phone nums.

HOME# cat user2.txt
PT: DARRELL SMITH
PTDOB: 12/15/98
RP: DARRELL SMITH SR
PTSSN: 558-55-1234
RPSSN: 554-55-1234
HMNUM: 213-555-1234B
RPNUM: 213-555-1234
POENUM: 213-555-1234B
HMADDY: 123 A yourstreet Los Angeles CA 90504
POENAME:
POEADDY:
CLIENT: TMC
DOS: 05/07/05

After trying many diff things i changed ghostdog's example and viola

awk '//{gsub(/B$/,"")}{print}' user2.txt


and now th results are in

HOME# awk '//{gsub(/B$/,"")}{print}' user2.txt
PT: DARRELL SMITH
PTDOB: 12/15/98
RP: DARRELL SMITH SR
PTSSN: 558-55-1234
RPSSN: 554-55-1234
HMNUM: 213-555-1234
RPNUM: 213-555-1234
POENUM: 213-555-1234
HMADDY: 123 A yourstreet Los Angeles CA 90504
POENAME:
POEADDY:
CLIENT: TMC
DOS: 05/07/05
HOME#

Thanks GDog
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0