Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using cut to create a new file

Status
Not open for further replies.

ryanc2

MIS
Apr 18, 2003
73
US
I have a fixed length file that I need to strip certain fields out and generate a new file. Each line needs to start with DCHANGE and end with 000000~~~ (both of which are not in the input file). I tried to cut out the positions I want, but in the output file, they need to be in a different order, of which cut doesn't seem to like.

Any help would be appreciated.
 
all of this sounds hypothetical unless you post your sample input and a desired output (along with the explanation).

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
man awk

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
sorry for the lack of input.

Sample Input File:

123455 A1 Customer Name YNY 5000.00 JCH 12345 Main Street

----------

I've tried to use awk, but I can't get it to grab each individual fields. For example, the YNY are actually three Y/N flags.

I've tried to use cut -c and reposition to a new output file, but it is not using the order. For example,

cat input_file | cut -c1-7, 20-25, 12-15 > output_file

This will not put the fields in that order, but instead rearranges them in the order of the original positioning.

The output_file needs to look something like this:

DCHANGE123455 A1 Customer Name 12345 Main Street JCH YNY 000000~~~

Thanks again
 
In the awk man page take a look at the substr function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top