Sponsored Content
Top Forums UNIX for Dummies Questions & Answers String substitutions in ASCII files - Post 23972 by Perderabo on Wednesday 3rd of July 2002 09:16:51 AM
Old 07-03-2002
The exact best approach would depend on the details of your particular system. It always amazes me when folks ask questions without revealing what version of unix, what computer, etc. Well, I'll this a shot anyway.

The fastest way to do anything is to write a carefully designed assembly language program that will fully exploit the features available on your system. Following close behind would be writing the program in C.

As far as scripts go, the fastest way to to perform the two tranformations that you mentioned is this:
Code:
#! /usr/bin/sed -f
s/London/X1/g
s/Frankfurt/X2/g

You might call it "scramble" and run it like this:
./scramble < inputfile > outputfile

But you want to do 400 substitutions. sed will have some limit on the number of commands that it can handle. It is not likely that you can get all 400 in one script. You can probably get 100, but the exact limit depends on your version of unix. You could have 4 of these, like this:
./scramble1 < input | ./scramble2 | ./scramble3 | ./scramble4 > output
If your computer has at least 4 cpu's this might still be unbeatable by any other scripted solution.

The latest version of ksh, ksh93, has much of sed built-in. A carefully written ksh93 script that relies only on built-ins could probably beat the pipeline of sed scripts. But most folks only have ksh88 available.

Try the sed solution and see where that leaves you.

Last edited by Perderabo; 07-03-2002 at 10:22 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ASCII Files

Can you pls help on writing ASCII files? For example, how to you put SUPPLIER NO and NAME in an ASCIIfile? (1 Reply)
Discussion started by: yialousa
1 Replies

2. Programming

open ASCII files

Anyone knows how to open an ASCII file by using C Thanks :D (2 Replies)
Discussion started by: Wing m. Cheng
2 Replies

3. UNIX for Advanced & Expert Users

viewing binary files in ASCII

Hi, How to view binary files in ASCII format.???????????????? Bye (2 Replies)
Discussion started by: manjunath
2 Replies

4. Shell Programming and Scripting

Replace characters in a string using their ascii value

Hi All, In the HP Unix that i'm using when i initialise a string as Stalled="'30¬G'" Stalled=$Stalled" '30¬C'", it is taking the character ¬ as a comma. I need to grep for 30¬G 30¬C in a file and take its count. But since this character ¬ is not being understood, the count returns a zero. The... (2 Replies)
Discussion started by: roops
2 Replies

5. UNIX for Dummies Questions & Answers

sorting ASCII string containing numbers

I have the following output where I need to sort the second column numerically (starting with IBMULT3580-TD10 and ending in IBMULT3580-TD123) Drv DriveName 0 IBMULT3580-TD13 1 IBMULT3580-TD18 2 IBMULT3580-TD14 3 IBMULT3580-TD10 4 IBMULT3580-TD11 5 IBMULT3580-TD17 ... (8 Replies)
Discussion started by: GKnight
8 Replies

6. UNIX for Dummies Questions & Answers

Finding and using (only) ASCII files.

Hi, I had to do something I could do in a way that worked fine, but I'm still wondering if there's a shorter way (which I think there is)... I had to find only the ASCII files of a directory, and then work with them (that is, not only showing on screen) What I did was ls | xargs... (4 Replies)
Discussion started by: Casey
4 Replies

7. UNIX for Dummies Questions & Answers

From Ascii files to Excell

Hi, Is there anyway to copy a certain column from the Ascii file into a column on an Excel sheet? Thanks, (4 Replies)
Discussion started by: cosmologist
4 Replies

8. UNIX for Advanced & Expert Users

line endings help of non-ASCII files

When you are dealing with ASCII files it easy to check on line endings type. You can just use the file command. You are not always lucky enough to be dealing with ASCII files. So in the cases that you don't have ASCII files how can you check what type of line endings you have? Please list all... (5 Replies)
Discussion started by: cokedude
5 Replies

9. Shell Programming and Scripting

Multiple Substitutions across Multiple Files

Hey everyone! I am determining the best method to do what the subject of this thread says. I only have pieces to the puzzle right now. Namely this: grep -rl "expression" . | xargs open (I should mention that the intention is to grep through many files containing the "expression" and... (2 Replies)
Discussion started by: Alexander4444
2 Replies

10. Shell Programming and Scripting

Replace alphabets in a string with their ASCII values

hi. I have a requirement where I need to REPLACE all alphabets from an alphanumeric input string into their respective ASCII decimal value. For example: If the input string is ABAC123, the output should be 65666567123 I am seeking a single line command, and I was trying searching for options... (21 Replies)
Discussion started by: kumarjt
21 Replies
mech(4) 						     Kernel Interfaces Manual							   mech(4)

NAME
mech, qop - security mechanism and quality of protection (QOP) files SYNOPSIS
DESCRIPTION
The and files contain tables showing installed security mechanisms and the Quality of Protection (QOP) associated with them, respectively. These files are accessed by GSS-API calls; see gssapi(5). As security mechanisms are installed on the system, entries are added to these two files. Contents of these files may be accessed either manually or programmatically; for example, manually with cat(1) or more(1), or programmati- cally with either rpc_gss_get_mechanisms(3N) or rpc_gss_get_mech_info(3N). /etc/gss/mech The file contains these fields: mechanism name ASCII string representing the mechanism. object identifier OID for this mechanism. shared library Shared library which implements the services provided by this mechanism. kernel module Kernel module which implements the services provided by this mechanism. /etc/gss/qop The file contains these fields: QOP string Name, in ASCII, of this Quality of Protection. QOP value Numeric value by which QOP can be identified. mechanism name ASCII string representing the mechanism with which this QOP is associated. EXAMPLES
Example 1: A Typical Entry in Example 2: A Typical Entry in AUTHOR
and were developed by Sun Microsystems, Inc. SEE ALSO
rpc(3N), rpc_gss_get_mechanisms(3N), rpc_gss_get_mech_info(3N), rpcsec_gss(3N), gssapi(5). mech(4)
All times are GMT -4. The time now is 01:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy