05-29-2009
Replacing File values
Currently I am using the tr command in 3 scenarios for a ksh script.
1) Replacing any spaces in the file with a ~
tr ' ' '~' <$orignalFile> $newFile
2) After certain processing is done at the end of the scirpt i convert the Tilde back to spaces
tr ' ' '~' <$newFile> $newFile2
3) Last I need to remove any carriage return from the file.
tr -d '\r' <$newFile2> $newFile3
Currently the script works however I am left with 2 extra files that I delete within the script. Is there a more effective way of acheiving what I listed above without having to create 3 new files, I guess I'm suprised when issuing the TR command it doesn't allow you to copy to the same file which i have tried mutlpie times without success ie..
tr ' ' '~' <$orignalFile> $originalFile
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Replace disable_functions in php.ini with value of your choice which may be different on different servers
================================================
-bash-2.05b# grep disable_functions /usr/local/lib/php.ini
disable_functions = 1 2 e weq t ret rye y etyhty rt et e
... (3 Replies)
Discussion started by: fed.linuxgossip
3 Replies
2. Shell Programming and Scripting
Hi
I have 2 files:-
1. List of files which consists of names of some output files.
2. A delimited file; delimted by "|"
I want to replace the value of the $23 (23rd column) in the delimited file with name in the first file. It is always position to position. Meaning first row of the first... (5 Replies)
Discussion started by: pparthiv
5 Replies
3. Shell Programming and Scripting
Please help me with an shell / awk script to achieve following;
File-1:
ABCDW01 12322 23322
BDADW01 22232 24453
EDFAW00 32232 23422
and so on, notice that the first coloumn is a code and the another file contains the real value of each entry in the first colum above but not in a... (4 Replies)
Discussion started by: digipak
4 Replies
4. Shell Programming and Scripting
I want to replace string values from a file to a file
For eg : File1 has 30 lines of string with values, those specific values needs to be changed in file2 and remaining values in file2 should be as it is.
For example:
From file (File1)
cluster.name=secondaryCluster
To replace File... (9 Replies)
Discussion started by: sriram003
9 Replies
5. Shell Programming and Scripting
hi all ,
( perl)
i am trying to replace jst one column in a file for eg
month dayofweek dealar car-name
jan thurs mercedes c300
feb wed lexus is300
all this data is in a master file and i want to replace jan with 1
feb... (5 Replies)
Discussion started by: technoman
5 Replies
6. UNIX for Dummies Questions & Answers
Hi,
I have a tab delimited text file where some lines have the string "NA" in the second column. For these lines, I want to replace NA with the value in the first column, the symbol underscore followed by the value in the fourth column. How do I go about doing that? Thanks!
Input:
1 ... (3 Replies)
Discussion started by: evelibertine
3 Replies
7. Shell Programming and Scripting
Hi,
I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below...
if (start_new_rec=="true"){
exclude_user="false";
user=toupper($6);
match(user, "XXXXX.");
if (RSTART ==2 ) {
... (9 Replies)
Discussion started by: asandy1234
9 Replies
8. Shell Programming and Scripting
please consider the following file, there are repeated blocks of m values, and nested s values within. there are 2 columns (cols 3 and 4)associated with each m,s combination. All s1 rows must get a value of a(col 3 in output), all s2 values must get a value of b(col 3 in output). If s1 and s2 rows... (1 Reply)
Discussion started by: senhia83
1 Replies
9. UNIX for Dummies Questions & Answers
Hello All,
I am having the file as below .I need to replace column 9-12 with some other values. In the below file I need to replace 1509 to 1508 and 1508 to 1507 .Can you please help me in how to do that
Thanks,
Arun
... (10 Replies)
Discussion started by: arunkumar_mca
10 Replies
10. UNIX for Beginners Questions & Answers
Good day guys,
I'm having trouble in creating a logic when it comes to replacing the values inside a file.
I tried using sed command but it just doesn't work the way I want it to be.
Here is what I'm trying to achieve.
If my input file contains the values below.
NAME++GUEST1 ++GUESS2++... (3 Replies)
Discussion started by: asdfghjkl
3 Replies
exit(1) User Commands exit(1)
NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps
SYNOPSIS
sh
exit [n]
return [n]
csh
exit [ ( expr )]
goto label
ksh
*exit [n]
*return [n]
DESCRIPTION
sh
exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of
the last command executed (an EOF will also cause the shell to exit.)
return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe-
cuted.
csh
exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the
expression expr.
The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches
for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to
jump to a label that occurs between a while or for built-in command and its corresponding end.
ksh
exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8
bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing
a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit
except for a shell which has the ignoreeof option (See set below) turned on.
return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the
least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return
is invoked while not in a function or a '.' script, then it is the same as an exit.
On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways:
1. Variable assignment lists preceding the command remain in effect when the command completes.
2. I/O redirections are processed after variable assignments.
3. Errors cause a script that contains them to abort.
4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari-
able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not
performed.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5)
SunOS 5.10 15 Apr 1994 exit(1)