![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linux distro from bash script | Samtim74 | Shell Programming and Scripting | 1 | 08-19-2008 03:04 AM |
| Perl code to differentiate numeric and non-numeric input | Raynon | Shell Programming and Scripting | 11 | 08-04-2007 11:32 AM |
| how to numeric sort on field time | rahulspatil_111 | Shell Programming and Scripting | 1 | 04-27-2007 12:52 PM |
| Sort (bash command) | booboo | Shell Programming and Scripting | 5 | 03-31-2006 08:18 PM |
| Floating point numeric comparisions in bash | borncrazy | Shell Programming and Scripting | 2 | 03-27-2005 08:39 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
help newb at linux and bash need numeric script sort
I am trying to setup to automatically import a series of mysql database files. I am doing manually now and its a royal pain.
All the sql files are sequentially numbered in a format of 4 numbers underscore text with spaces replaced by underscores. example: Quote:
I figured I can do this to gain the proper structure file as they do not have duplicate numbers. Quote:
The variable h has the number alone and g has the full file name . Quote:
I have been looking at this code so long I can't see the forest for the trees, if you know what I mean. So any suggestions to get me on the right train of thought would be greatly appreciated Thanks, dlm1065 Last edited by dlm1065; 04-27-2008 at 04:36 AM.. |
|
||||
|
If you only use the output from find once, you don't really need to put it in a variable.
My suggestion would be to extract the sequence number and the database to separate fields, and sort numerically on the sequence number. Code:
find logon_updates -name "*.sql" -print | while read f do g=$(echo $f | cut -b15-) h=$(echo $f | cut -b15-18) echo $h:$g done | sort -t : -k1n Code:
... sort -t : -k1n | cut -d: -f2- | while read f; do sql PERFORM ACTS OF horror WITH "$f" USING BIG STICK done Maybe something like this would work already? Code:
find -name "*logon_structure.sql" -print | sort -t / -k2n Last edited by era; 04-27-2008 at 05:17 AM.. Reason: Oops, sort -t (not -d!) |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|