06-06-2008
read a variable character by character, substitute characters with something else
im having trouble doing this:
i have a variable with 2 characters repeating e.g. aababbbaaaababaabbaabbba
is there a way i can search the variable for a's and b's and then change a's to b's and b's to a's?
im guessing its like getting the 1's compliment of the string
im doing this in BASH, and ive looked into seeing if sed or awk could help but i got nothing
any help would be greatly appreciated
thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
How to read character by character using awk (6 Replies)
Discussion started by: karnan
6 Replies
2. AIX
i am a newbie to shell script,so i want a kshell script in which i need to check for a particular character inside a file through conditional looping(like if ,case,while)and if that character exists ,then substitute a given character to that character.
consider a file test.txt,inside the file... (1 Reply)
Discussion started by: karthikprasathk
1 Replies
3. Shell Programming and Scripting
How...
can I read input by a user character by cahracter. And assign each character from the string to a variable?
Any help would be greatly appreciated!
Thank you! (1 Reply)
Discussion started by: Tek-E
1 Replies
4. Shell Programming and Scripting
Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/
Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies
5. Shell Programming and Scripting
Hello all respected people,
Can i read a file character by character without using sed,awk and perl commands.
Thanks in advance. (4 Replies)
Discussion started by: murtaza
4 Replies
6. Shell Programming and Scripting
Hi All,
I have a big log file i want to delete all characters (between 350th to 450th characters) starting at 350th character position to 450th character position.
please advice or sample code. (6 Replies)
Discussion started by: rajeshorpu
6 Replies
7. Shell Programming and Scripting
hello all
i request you to give the solution for the following problem..
I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print
g
go
goo
goog
googl
google
like this Using unix Shell scripting...
without using... (1 Reply)
Discussion started by: samupnl
1 Replies
8. Shell Programming and Scripting
Hi ,
I have input file like below
Hi this is "vinoth".
Hi happy to work with 'unix'
USA(united states of America)
My script variables are below :
Dquote=Ộ
Squote=&#$567
Obrac=&^986
Cbrac=&^745
I want to read the variables in my SED command to replace the double quote,single... (9 Replies)
Discussion started by: vinothsekark
9 Replies
9. Shell Programming and Scripting
Hello,
I do have folders containing having funny strings in their names and one space.
First, I do remove the funny strings and replace the space by an underscore.
find . -name '* *' | while read file;
do
target=`echo "$file" | sed 's/... (2 Replies)
Discussion started by: tempestas
2 Replies
10. Shell Programming and Scripting
Hi friend,
I have one file , and i want to read that file character by character.
I need this script in ksh.
while using read option with -n1 am getting error.
while read -n1 c read has bad option
And if i am using below script, then if in a line has space like this ( Pallvi mahajan)... (10 Replies)
Discussion started by: pallvi_mahajan
10 Replies
LEARN ABOUT HPUX
unsetenv
setenv(3C) setenv(3C)
NAME
setenv(), unsetenv() - add, update or remove an environment variable
SYNOPSIS
Parameters
envname Points to a string containing the name of an environment variable to be added or altered. This should not be a NULL
pointer or null string, and the string should not contain an equal character.
envval Points to a string containing the value to be set for the variable envname.
overwrite Indicates whether to overwrite the value of envname variable or not, if it already exists. Expected values are non-zero
and zero. If the environment variable does not exist in the environment, then the value of this variable is ignored.
DESCRIPTION
and functions update the environment of the calling process.
If envname does not exist, the function ignores the value of overwrite and adds the variable envname to the environment with the value
envval. If envname exists and overwrite is non-zero, then the variable envname is updated with the new value envval. If envname exists
and overwrite is zero, then the variable is not updated, and the function is considered to have completed successfully.
The function deletes the variable envname from the environment, if it exists. If the envname variable does not exist in the current envi-
ronment, the environment is unchanged, and the function is considered to have completed successfully.
If the application modifies environ or the pointers to which it points, the behavior of and is undefined.
EXTERNAL INFLUENCES
Locale
The category determines the interpretation of characters in string as single- and/or multi-byte characters.
International Code Set Support
Single- and multi-byte character code sets are supported.
RETURN VALUE
The and functions return zero on success; otherwise they return and set to indicate the error.
ERRORS
If the function fails, is set to one of the following values:
Sufficient memory is not available to add a variable or its value to
the environment.
The envname argument is a null pointer, points to an empty string, or points to a string containing an equal character.
If the function fails, is set to the following value:
The envname argument is a null pointer, points to an empty string, or points to a string containing an equal character.
EXAMPLES
The following code adds a new environment variable to the current environment.
The following code updates the variable
The following code removes the variable from the current environment.
WARNINGS
The and functions manipulate the environment pointed to by environ, and can be used in conjunction with However, envp (the third argument
to main) is not changed.
The uses to enlarge the environment (see malloc(3C)).
After the or function is called, environment variables may not be in alphabetical order.
AUTHOR
and were developed by HP.
SEE ALSO
exec(2), getenv(3C), malloc(3C), putenv(3C), environ(5), thread_safety(5).
STANDARDS CONFORMANCE
setenv(3C)