![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MySQL article - Sun and MySQL: How It Stacks Up for Developers | iBot | UNIX and Linux RSS News | 0 | 02-28-2008 08:20 PM |
| MySQL conflicts with mysql-3.23.58-16.RHEL3.1 | johnveslin | Linux | 2 | 07-17-2007 03:49 AM |
| mysql would not start: missing mysql.sock | xnightcrawl | UNIX for Advanced & Expert Users | 2 | 05-26-2006 07:06 AM |
| PHP and MySQL | kwalick | UNIX for Dummies Questions & Answers | 2 | 04-23-2004 07:13 AM |
| MySQL problem >> missing mysql.sock | _hp_ | UNIX for Advanced & Expert Users | 8 | 11-03-2002 11:44 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
awk and mysql
Helloo,
I have worked with some files and so far I got to to point there I have a fileA: Person1_Operation20060611090814 Person4_Operation20060512090811 Person6_Operation20060613090214 Person2_Operation20060115090815 Person9_Operation20060617100814 .. ... ... so I was thinking is there a way to create file like this: Date|Time|Person|Operation 20060611|090814|Person1|Operation 20060611|090811|Person4|Operation 20060613|090214|Person6|Operation 20060115|090815|Person2|Operation 20060617|100814|Person9|Operation I was trying to to something with awk but it was useless.. Any help?? Also I have one more Q. I have mysql database on other Windows machine.. is there a way or how can I do that to conect to Mysql with shell script and do insert by shell script?? cherrs |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
This really depends on your input data ... is it all in fixed lenght fields as is sort of suggested by your example?
For exmple: Code:
awk '{printf("%s|%s|%s|%s\n",substr($0,18,8),substr($0,24,6),substr($0,0,7),substr($0,9,9));}' data.txt
EDIT: some numbers in the substrings were wrong Last edited by Unbeliever; 06-14-2006 at 07:46 AM. |
|
#3
|
|||
|
|||
|
Thanks...
of course just little edit on substr. but perfect..also I tryed to do this with cut command..and here what I tryed but it won't pass.. cut -f 1-6,8-24,25-32,25-32,33-38 -d '|' file1 > file2 of course mayve columns are not right one but I get on file2 exact a same file as file1... any adeas about mysql topic?? But thank U Unbeliever that worked perfect |
|
#4
|
|||
|
|||
|
If you install the same basic version of mysql on your unix machine as is running on your windows machine you can use the mysql client commands to connect to the remote windows installation (you dont need to start the database).
Code:
mysql -u <user> -h <hostname> -p <databasename> Reading the manual is best of course :-) |
|||
| Google The UNIX and Linux Forums |