I have to create some fixed width files using UNIX. The data source is an Oracle SQL query. If I use straight SQL and spool to a file everything comes out as expected.
Example Desired result (. indicate blank space):
V278814831..................................1743049591.10N
V154369133..................................1743049841.10N
If I perform the file creation using UNIX:
The file is created but every 8 spaces are automatically converted to tabs.
Example result (. indicate blank space, > indicate a tab equal to 8 spaces):
V278814831> > > > ..1743049591.10N
V154369133> > > > ..1743049841.10N
How can I prevent this automatic conversion? I have found way to revert the file to the desired state for example:
but I don't want to do this. I want to stop the tab conversion in the first place. How can I do this?
I have talked with several co-workers and no one knows the answer, only workarounds.
Please help...
Last edited by vbe; 09-28-2010 at 01:08 PM..
Reason: code tags please
spool in oracle writes a file using a separate fd, meaning it bypasses terminal I/O.
Redirection > takes terminal output from the terminal driver and sends it to a file
The only way around it is to change the terminal or use spool inside the SQL.
I like changing the SQL code, not the terminal settings, because terminal changes can mess up lots of other things.
This User Gave Thanks to jim mcnamara For This Post:
@ jim mcnamara
I'm relatively new to UNIX, can you spool to a UNIX directory from within a SQL script? If so, how? That's what I wanted to do in the first place but my co-workers said it's not possible.
You can use the Oracle "SPOOL" command from SQL on a unix server.
It is no different from other platforms.
The "SPOOL" method is much better than using unix Shell commands to redirect output intended for a screen to a file.
Tried the spool and it works. I guess I just learned a valuable lesson... My co-workers pretendto know UNIX. Next time I won't take what they say as gospel and try it for myself, which is what i usually do. I don't know what came over me.
Hello All,
Could you please do help me here as I would like to perform parameter expansion in shell over a parameter expansion.
Let's say I have following variable.
path="/var/talend/nat/cdc"
Now to get only nat I could do following.
path1="${path%/*}"
path1="${path1##*/}"
Here... (8 Replies)
(Using Bash 4.4)
When I write something like dir="~/dox"
ls $dir then I get the message that the directory '~/docs' does not exist. I understand that the tilde is not expanded at the time of the above assignment because of the quotes. But why is it not expanded at the time when the ls command is... (2 Replies)
I have a bunch of files which I need to transfer to another location... and some of these I need to skip.
For e.g. let us say the files are:
cust_abc.dat
cust_xyz.dat
cust_def.dat
and I only want to move the first two.
I want to do something like:
cp cust_.dat <target>
... (1 Reply)
Hi
I have an input file which have random file in between.I have to manipulate each line and replace the character from position 5-10 with XXXXXX.
But when I am writing this to on output file the tabs in between gets converted to normal space.
Input file :
14207531131040896334R108 ... (4 Replies)
Hi ,
could anyone help me out with this problem.
sample.txt has this content :
u001- this is used for project1 ||
u002- this is used for p2|| not to be printed
u003- this is used
for project3 ||
u004- this is
used for p4 ||
u005- this is used for project5 ||
u006- this is used for p6... (9 Replies)
Hi All,
I am facing issues converting white spaces and tabs together in a file I am reading. Here is the command I am trying:
tr -s ' '@ | sort -t@ +1n filename
I guess the problem is that it is not converting the tabs to another delimiter. Also, I am supposed to accomplish this only using... (5 Replies)
I have a script that takes an option for server pools to run the script against. The option is given as a comma separated list (ie, -p 201,204,301).
I'm using eval and brace expansion to get those pool numbers into an array. It works fine unless only 1 pool number is given. Here's the code:
... (5 Replies)
Hi,
I have a script that at one point prints to a file as follows:
printf -- $2 > ~/.mydir/$1
The idea is to print to a hidden directory .mydir in my home directory. I've already sanitized the inputs and $1 is in the format path1/path2/filename and $2 is some user input.
When I run this... (2 Replies)
All,
I have a shell script which executes the below command
find $1 -name $2 -print > ${Backup}/FileFind.txt
I have $2 sometimes coming with the below values.
.*
When I go to the log after the execution of the script, .* gets expanded to .developer.adm instead of searching for all... (5 Replies)