|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
i really need some help here, have been asked to write a shell script to grab data from a report, please find attached a sample report that i need to work on, could somebody please tell me how to grab say data from column "Book Value" ??
, i don't know how to get rid of the header above the column headings, please suggest the best approach to solve this problem, any help is greatly greatly appreciated |
|
#2
|
|||
|
|||
|
not really easy
the output file is not constant, not structured assumin you are on *nix, 'cut' and 'sed' can help you a) try a position guess, it seem to be constant ' 40,213.03 JAPANESE YEN 1.00' the length of this string give (maybe) the start pos of the required value cut -cX,Y filename where X is strlen of that string and Y is max len of expected output then pipe this to sed, purging all spec char like spaces,(),komma, punct and so on cut -cX,Y filename ¦ sed 's/[,\.()]//g;s/ [ ]*$//;s/ [ ]*//g/' i explain the sed, remember the X Y values are IMPORTANT a) take off all punctiation and () b) kill AT END all spaces c) kill AT BEGIN all spaces NOT TESTED, just a guess |
|
#3
|
|||
|
|||
|
thank you very much for your reply
, have been asked to use awk tho, any insights anybody ![]() |
|
#4
|
|||
|
|||
|
Quote:
I have no time to study the structure of your file, but if I were you, I would try to write a script that prints out specified lines and specified columns. "KISS" - keep it stupid and simple. It is at least the first approach. Try this: : [ $# -eq 4 ] || { echo "$0: call $0 first_line last_line col_start col_end" >&2 exit 1 } awk ' NR>='$1' && NR <='$2' {print substr($0, '$3', '$4'-'$3'+1)} ' Use copy and paste, all these sily apostrophes are significant. Send standard input into the script. Regards ![]() |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > grabbing data from columns |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|