This is VERY disturbing. The command:
will NOT do what you said it will do on any Linux system, on any UNIX system (including AIX), nor on any BSD system.
You haven't bothered to tell us what shell you're using, but with any of the common shells available on any of the systems listed above that I am aware of, the above command will do the same thing on every one of those systems: truncate abc.txt so that it will be an empty file.
If you weren't redirecting output to your input file (thereby destroying your input file before cat and sed ever see it), you are still using single quotes that cause $a and $b to be treated as literal strings instead of having the shell expand them.
If you want to run a script on an AIX system and on a Linux system and have it behave the same way on both of those systems, you cannot use options that are only available on one of those systems.
If you expect us to help you, you need to show us the actual results that you are getting on both systems. I.e., show us:
the contents of your file before you run your command(s) on your Linux system (in CODE tags),
the contents of the variables you are using in your commands on your Linux system (in CODE tags),
any diagnostic messages printed while running your command(s) on your Linux system (in CODE tags),
the contents of your file after you run your command(s) on your Linux system (in CODE tags),
the contents of your file before you run your command(s) on your AIX system (in CODE tags),
the contents of the variables you are using in your commands on your AIX system (in CODE tags),
any diagnostic messages printed while running your command(s) on your AIX system (in CODE tags), and
the contents of your file after you run your command(s) on your AIX system (in CODE tags),
and tell us:
what Linux distribution you're using (including version number),
what shell you're using on your Linux system (including version number),
Hi All,
I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text.
An example of 4 lines in my file is:
1. MatchText_randomNumberOfText moreData ReplaceMe moreData
2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Hi All,
My requisite is to search for the string "0108"(which is the year and has come in the wrong year format) in a particular column say 4th column in a tab delimited file and then replace it with 2008(the correct year format) in the same position where 0108 was found in the same file..The... (27 Replies)
Hello,
I really would appreciate some help with a bash script for some string manipulation on an SQL dump:
I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump.
This is quite easy with sed:
sed -e... (1 Reply)
I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios.
Cat test
Nov 10, 2012 5:17:53 AM
INFO: Request Type
Line 1.... (5 Replies)
Hi Everyone,
I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file.
I am very new to unix. Kindly help... (10 Replies)
I am trying to write shell script to find and replace using Sed. but i am unable to complete the setting. need help in doing that.
Requirement:
FROM
"${O_INSTANCE}/diag/logs/${C_TYPE}/${C_NAME}/httpd.pid"
TO
"/var/opt/<SID>_<HOSTNAME>/Apache/httpd.pid" (10 Replies)
My variable contains the following string
I wish to replace \n with "space" so the expected output is:
I understand that the /n is not a new linein this case.
I'm on AIX using ksh shell. Below is all that I tried.
echo $str | sed -e "s#\n# #g";
echo $str | sed -e "s#\n#' '#g";... (5 Replies)
I have the below string which i need to compare with a file and replace this string in the file which matches closely. Can anyone help me on this.
string(Scenario 1)- user::r--,user::ourfrd:r--
String(Scenario 2)- user::r--
File
****
# file: /local/Desktop/myfile
# owner: me
# group:... (6 Replies)