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
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 08:12 PM
Find and replace some line johnl Shell Programming and Scripting 1 05-22-2008 03:54 AM
Mac address - what is line command to find and active new card wmetz IP Networking 1 03-19-2002 04:44 PM
cant find command that returns blank line jeffersno1 UNIX for Dummies Questions & Answers 2 11-15-2001 04:14 PM
replace text in a file from the command line... dudboy UNIX for Dummies Questions & Answers 1 09-04-2001 02:31 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-12-2005
vasikaran vasikaran is offline
Registered User
  
 

Join Date: Jun 2005
Location: india
Posts: 55
find and replace command in one line using one command

Hi,

I have a entry in the file as

::BSNL GUJARAT::India::OUT::NAT::REWEL::POSTPAID::919426199995

if u see this, i have the delimiter as :: ,

all i want is to replace "::" as ":"

so how to do that..

pls help

thanks
  #2 (permalink)  
Old 08-12-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Code:
echo "::BSNL GUJARAT::India::OUT::NAT::REWEL::POSTPAID::919426199995" | sed -e 's#::#:#g'
Vino
  #3 (permalink)  
Old 08-12-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,206
Since you want to make this change ':' cannot be a legal character in the fields and so this will also work.

Code:
echo "::BSNL GUJARAT::India::OUT::NAT::REWEL::POSTPAID::919426199995" | tr -s ':'
Be aware that this change will damage your data if ':' is a legal value, for example in a date.

Last edited by reborg; 08-12-2005 at 03:44 PM..
  #4 (permalink)  
Old 09-04-2007
msubbums msubbums is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 7
Smile use perl

by perl u can do the following

perl -pi -e 's/::/:/g' <filename>

This replaces ur '::' to ':' in the file directly.
  #5 (permalink)  
Old 08-20-2008
wip_vasikaran wip_vasikaran is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 14
how to use sed command to find and replace a directory

i have a file.. which contains lot of paths ...

for eg.. file contains..

/usr/kk/rr/12345/1
/usr/kk/rr/12345/2
/usr/kk/rr/12345/3
/usr/kk/rr/12345/4
/usr/kk/rr/12345/5
/usr/kk/rr/12345/6
/usr/kk/rr/12345/7
/usr/kk/rr/12345/8

i want to replace /usr/kk/rr/12345/ with /usr/kk/yy/12555/

pls help
  #6 (permalink)  
Old 08-20-2008
narayana123 narayana123 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 1
$sed 's/::/:/g' source file>destination file
  #7 (permalink)  
Old 08-20-2008
wip_vasikaran wip_vasikaran is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 14
actually u have replied for my ealier posts.. pls refer above, i am trying to rename a directory...

i can do with normal texts.. but i am not able to rename the directories pls help
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 08:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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