[SGVLUG] awk question

Ramsin Savra ramsinsavra at yahoo.com
Wed Aug 30 11:25:27 PDT 2006


 
  Hi Mathew,
   
  Sure. I have a CSV file and I need to extract two first columns. Consider it as following:
   
  ****************************************************
"ID","Name","RS","Column","Created On","Last Modified"
"4","STUDENT TABLE","DB 001","UINT:Time
UINT:User ID
VARCHAR1:User Name
VARCHAR4:Data","2006/08/09:12:47:51","2006/08/09:12:47:51"
  
"5","TEACHER TABLE","DB 002","UINT:Time
VARCHAR4:Request
VARCHAR4:Response
UINT:Response Time","2006/08/09:12:47:51","2006/08/09:12:47:51"
***************************************************
  In command line I do:
  cut -f 2  file1.tmp | grep "DB" | awk ' {print $0} ' | cut -f 1-2 d, > tables_list.tmp
   
  then tables_list file has:
   
  "4","STUDENT TABLE"
  "5","TEACHER TABLE"
   
  Then I use sed command to remove double quotes and ...
   
  Now. when I use awk is my script instead of replacing $0 with a line from the text file it replaces it with script name. I need to override this.
   
  Any suggestions?
  Thanks in advance.
   
   
  ~

matti <mathew_2000 at yahoo.com> wrote:
  

--- Ramsin Savra wrote:

> 
> Hello Group,
> 
> I have a quick question about awk. In command line using awk ' {
> print $0} '
> is not a problem but when I want to use it in a script it causes
> problem. since it points to the name of the script but I need to use
> it for a different purpose which is printing a line from a CSV file.
> 
> Would you pelase give me some advice on this?

Could you restate this, perhaps an example??

thanks
matti


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


 		
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates starting at 1¢/min.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.sgvlug.net/pipermail/sgvlug/attachments/20060830/dbfa4521/attachment.html


More information about the SGVLUG mailing list