Ksh in Linux Removing: "\0" From String


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ksh in Linux Removing: "\0" From String
# 1  
Old 08-18-2010
Question Ksh in Linux Removing: "\0" From String

Hi All,

I am facing a problem and I am not able to solve it.

I have already searched google, but nothing (maybe I am not using the correct key words).

As a database query result, I have a file like below:
Code:
[testServer]fmv:/home/fmv/tmp>cat TestBackRef.txt
/^TEST\([0-9]\{4\}\)X[0-9]\{12\}Y\.txt$/\0#\1/#Test File - Test.txt

The query result mean, char "#" as separator:
Code:
awk -F"#" '{print $1 "#" $2}' TestBackRef.txt # => sed regex
/^TEST\([0-9]\{4\}\)X[0-9]\{12\}Y\.txt$/\0#\1/

Code:
awk -F"#" '{print $3}' TestBackRef.txt # => regex description
Test File - Test.txt

From my script, when I try to read this file, the "\0" is not showing, check below:
Code:
[testServer]fmv:/home/fmv/tmp>while read -r fPattern
do
 echo "${fPattern}"
done < TestBackRef.txt
> > > /^TEST\([0-9]\{4\}\)X[0-9]\{12\}Y\.txt$/#\1/#Test File - Test.txt

In fact, I am adding each row in this file to an array.

Why this is happening? Smilie

I know if I add one more backslash before the number "0", it works, but I don't want to do this.

I am in a RH linux box with ksh.

Thanks!
# 2  
Old 08-18-2010
Hi, I tried it in bash and in ksh93 on Ubuntu and I cannot reproduce this; "\0" is showing, Are you sure you are using a genuine ksh and not pdksh ?
# 3  
Old 08-19-2010
Hi Scrutinizer,

I didn't realized this, my ksh version is the PD KSH!
==========================
#echo $KSH_VERSION
@(#)PD KSH v5.2.14 99/07/13.2
==========================
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

2. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

3. Shell Programming and Scripting

Removing "^M" from the end of a String (i.e. "Ctrl+M")?

Hello All, I have an Expect script that ssh's to a remote server and runs some commands before exiting. One of the commands I run is the "hostname" Command. After I run this command I save the output using this line in the code below... Basically it executes the hostname command, then I... (2 Replies)
Discussion started by: mrm5102
2 Replies

4. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

5. Shell Programming and Scripting

Purpose of "read" and "$END$" in ksh ?

Hi, Could anyone please shed some light on the following script lines and what is it doing as it was written by an ex-administrator? cat $AMS/version|read a b verno d DBVer=$(/usr/bin/printf "%7s" $verno) I checked that the cat $AMS/version command returns following output: ... (10 Replies)
Discussion started by: dbadmin100
10 Replies

6. Shell Programming and Scripting

sed - extract string before "/" from variable- linux 2.6.9-89

Hi, I have a FTP script which gets called from a wrapper script that exports a variable having value as: "/export/home/dips/logs/dipsSFTP_file1.log.YYYYMMDDHHMISS". I want to extract the file name "dipsSFTP_file1.log.YYYYMMDDHHMISS" and the dir path "/export/home/dips/logs/" from this... (4 Replies)
Discussion started by: dips_ag
4 Replies

7. Shell Programming and Scripting

input string="3MMTQSZ348GGMZRQWMJM4SD6M";output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6

input string="3MMTQSZ348GGMZRQWMJM4SD6M" output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6M" using linux shell script (4 Replies)
Discussion started by: pankajd
4 Replies

8. HP-UX

script running with "ksh" dumping core but not with "sh"

Hi, I have small script written in korn shell. When it is called from different script, its dumping core, but no core dump when we run it standalone. And its not dumping core if we run the script using "/bin/sh" instead of "ksh" Can some body please help me how to resolve this issue. ... (9 Replies)
Discussion started by: simhe02
9 Replies
Login or Register to Ask a Question