LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-18-2007, 02:24 AM   #1
yongitz
Member
 
Registered: Nov 2005
Location: Davao City, Philippines
Distribution: RHEL, CentOS, Ubuntu, Mint
Posts: 139

Rep: Reputation: 20
find certain character and replace with a number


Hi all!
I have a txt file that contains the character "|" as a separator.. Could it be done in a shell script to automate things such that if I find the "|" character it would be replaced by a number and first "|" as 1 and so on.. So if my txt file contains 100 "|" so the first | is 1 and the last is 100.
 
Old 01-18-2007, 07:40 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
This sounds a bit too involved for a shell script.

I recommend that you learn Perl, which will be adequate for this.

Instead of Perl, you could use awk. That would probably also work, but Perl will give you a more general tool that you can use in more future situations than awk.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
find and replace happy78 Programming 11 09-10-2005 10:21 AM
replace a string/number in a text file jpan Linux - General 3 10-22-2004 09:33 PM
Perl - Tpl file - Need to replace new line character. knnirmal Programming 2 09-07-2004 02:27 PM
How do I add character+number to get char in C++? needforspeed Programming 10 02-10-2004 12:16 AM
convert a character in a box to keycode number Linh Programming 3 10-14-2003 04:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration