View ouput as a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting View ouput as a file
# 1  
Old 11-11-2010
View ouput as a file

Hi all ,

I have a view in teradata , the ouput of that view have to be stored as a file with delimitere as '|'.Is there any possibility of doing this in unix ?


Thanks in advance ,
Vinoth
# 2  
Old 11-11-2010
Can you give a sample input and output you are expecting.....
# 3  
Old 11-11-2010
I dont have any sample file with me right now . From the view , i will get the output as a table.I have to extract the data from the table and then have to write it in the file .

sample input(TABLE)
Code:
col1    col2    col3 
 12      14       15
 34       13       23

Expected result(FILE)
Code:
12|14|15
34|13|23

# 4  
Old 11-11-2010
Code:
sed "s/^ *//;s/ *$//;s/ \{1,\}/|/g" inputfile > outputfile.txt

The above should work
# 5  
Old 11-11-2010
Try:
Code:
awk '{$1=$1}1' OFS="|" infile

or
Code:
awk '{$1=$1}NR>1' OFS="|" infile

to lose the header..
# 6  
Old 11-11-2010
Hi Scrutinizer
can you please explain
Code:
awk '{$1=$1}1'

.
i am new to awk, how does the above code work...

Thanks!!!!
# 7  
Old 11-11-2010
Hi raghu, in awk, if any of the fields ($1, $2 etc) gets a new value the enitre record (in this case a line) gets recalculated and the output field separator is applied so that it now contains "|" instead of tabs or spaces. After the brackets the "1" ensures that the recalculated records get printed..
This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

Moving from Desktop View to Mobile View

See attached video for a demo on how to move back and forth from the desktop view to the mobile view. Currently this only works for the home page, but I will work on some new PHP code in the future to make this work with the page we are currently on. Edit: The issue with making every page ... (2 Replies)
Discussion started by: Neo
2 Replies

2. UNIX for Beginners Questions & Answers

View file flags

hello: how could i view the file's flags? "ls -loa" doesn't seem to do the trick: root@giraffe:/etc # ls -alo total 820 drwxr-xr-x 23 root wheel - 2048 Oct 23 19:48 . drwxr-xr-x 19 root wheel - 1024 Nov 16 15:01 .. drwxr-xr-x 2 root wheel - 512 Nov 11 2014 X11... (6 Replies)
Discussion started by: ipfreak
6 Replies

3. Shell Programming and Scripting

Inserting ouput into a file using redirection

Hallo Team, I would like to redirect an output from a file into another file. Here are the two commands/files. -bash-3.2$ cat lack.csv lemontwistpax -bash-3.2$ ll -ltr BW*|tail -1 -rw-r--r-- 1 mind mind 1844 Sep 25 12:06... (8 Replies)
Discussion started by: kekanap
8 Replies

4. UNIX for Dummies Questions & Answers

Wget ouput to log file

Hi all The following code will update the Dynamic DNS server at Namecheap.com. wget -O 'https://dynamicdns.park-your-domain.com/update?host=www&domain=example.com&password=your DDNS password'Would like to append the output to a log file using >> /path/path/logfile at the end of the command. ... (7 Replies)
Discussion started by: CRChamberlain
7 Replies

5. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

6. Shell Programming and Scripting

how to view unix file ?

Hi to all, 1- I'm trying to open a certain file in unix with the tool KEA! 2- i get to the correct folder with the CD command 3- Once in the correct directory i try the following unix command: vi NameOfFile.Z 4- Yes those files finish with a .Z 5 - I get something in the KEA!... (3 Replies)
Discussion started by: Sanchoniathon
3 Replies

7. Red Hat

How to view .dat file?

What is the command that can be used to open or view the .dat file in linux? Unable to read the contents of .dat file. (7 Replies)
Discussion started by: Rupaa
7 Replies

8. UNIX for Dummies Questions & Answers

not able to view the file

Hi All, I am experiencing a strange and serious issue. I can see, a file exist there inside a directory while doing cat i can see the file exists, but while trying to view that its saying NO such File or Directory. (ipbala01)/env/balast7/app/working/batch_loader/data/system_2/input>ll total 12... (8 Replies)
Discussion started by: gotam
8 Replies

9. Solaris

How do I view file?

I am trying to view the files in /etc/security/audit/SERVERNAME/files, but when I gunzip them and then do a cat I get a bunch of garbage with some stuff that makes sense. I need to view this file without having all the garbage. I tried to cat it and vi it without any luck. Can someone show me an... (4 Replies)
Discussion started by: jastanle84
4 Replies

10. Shell Programming and Scripting

Limit ouput file on a shell script

I have this one::) doing jstack on JVM proccess. #!/bin/ksh # ---------------------------------------------------- # capture_jstack.sh <INTERVAL> <COUNT> # run jstack and capture output to a log file #----------------------------------------------------- # # scripts and logs are stored... (3 Replies)
Discussion started by: pointer
3 Replies
Login or Register to Ask a Question