01-07-2002
Finding a column in a flatfile
I have a file which is fixed width columns. This is an offset buffer - rather than space or tab delimited. There are upto about 8 columns and I need to get all of the column 5's values into another file.
The problem is that because the delimiter is a space - and some fields are blank - the 5th field is sometimes taken as the 6th - so I lose quite a bit of data.
I want to find a way to output just the values from the 50th - 60th positions on the line into another file - for all lines in a large text file.
Ideally I'd like to get two columns for each line.....but I imagine that should be easy enough if I can figure out how to get the column I want.
I tried " awk -F" " '{print $5 "," $1 }' " - but this gives me the problem...any ideas?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have a file with 3 columns in it that are comma separated and it has about 5000 lines. What I want to do is find the most common value in column 3 using awk or a shell script or whatever works! I'm totally stuck on how to do this.
e.g.
value1,value2,bob
value1,value2,bob... (12 Replies)
Discussion started by: Donkey25
12 Replies
2. Shell Programming and Scripting
I have a set of flatfiles which have columns delimited by #. How can a particular column be deleted in all the flatfiles. All flatfiles have same number of columns. (5 Replies)
Discussion started by: rsprabha
5 Replies
3. Shell Programming and Scripting
I have a small script where I want to see if a file exists & then delete the first line from it.
I have code to help me find if the file exists, but I am unsure as to how to then take in the answer and remove the first line from the flatfile:
This is what I have so far just to output if the... (3 Replies)
Discussion started by: fatalxkiss
3 Replies
4. Shell Programming and Scripting
Hi, been about 10 years since I've scripted, so very rusty and could use some quick help.
I have a file that contains data like such:
folder1 jondoe owner janedoe reader joeshmo none
folder2 jondoe none janedoe none joeshmo owner
folder3 jondoe owner
folder4 janedoe owner joeshmo... (7 Replies)
Discussion started by: drewpark
7 Replies
5. Shell Programming and Scripting
Hi,
I need to find out the last column value from a text file which is delimited by a tab.
The issue here is the last column# for each record can be different i.,e, 1st record can have the last column as 15 and the second record can have the last column as "17".
I have to search a string... (3 Replies)
Discussion started by: naveen_sangam
3 Replies
6. Shell Programming and Scripting
Can any one tell me how to get the second last column value from the text file, which has different record size for each record.
I know how to get the last column using awk and print statements, but I am unable to get the second last column value from the file. (4 Replies)
Discussion started by: naveen_sangam
4 Replies
7. Shell Programming and Scripting
Hello,
I am trying to get a script to work which will find the maximum value of the fourth column and assign that value to all rows where the first three columns match.
For example:
1111 2222 AAAA 0.3
3333 4444 BBBB 0.7
1111 2222 AAAA 0.9
1111 2222 AAAA 0.5
3333 4444 BBBB 0.4
should... (8 Replies)
Discussion started by: jaysean
8 Replies
8. UNIX for Dummies Questions & Answers
Hi,
I have 2 files:
file1:
1 ia 2
1 mn 6
1 sd 11
2 ny 3
2 ma 10
3 wa 7
3 ca 8
file2
1 mi 3
1 wi 5
2 pa 4
3 id 6 (2 Replies)
Discussion started by: peanuts48
2 Replies
9. Shell Programming and Scripting
Please help me how can I display every nth field present in a "|" delimited file.
Ex: If a have a file with data as a|b|c|d|e|f|g|h|k|l|m|n
I want to display every 3rd feild which means the output should be
c
f
k
n
Please help me. (1 Reply)
Discussion started by: ngkumar
1 Replies
10. Shell Programming and Scripting
hi,
Am trying to find a solution for finding a null column value inside a loop using array.
for eg:
two
three
five
From the above array myarray,myarray and myarray having null values. But when am trying to check that space using some condition its not working.
for (( i=0;... (4 Replies)
Discussion started by: rogerben
4 Replies
FOLD(1) BSD General Commands Manual FOLD(1)
NAME
fold -- fold long lines for finite width output device
SYNOPSIS
fold [-bs] [-w width] [file ...]
DESCRIPTION
The fold utility is a filter which folds the contents of the specified files, or the standard input if no files are specified, breaking the
lines to have a maximum of 80 columns.
The options are as follows:
-b Count width in bytes rather than column positions.
-s Fold line after the last blank character within the first width column positions (or bytes).
-w width
Specify a line width to use instead of the default 80 columns. Width should be a multiple of 8 if tabs are present, or the tabs
should be expanded using expand(1) before using fold.
ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of fold as described in environ(7).
SEE ALSO
expand(1), fmt(1)
STANDARDS
The fold utility conforms to IEEE Std 1003.1-2001 (``POSIX.1'').
BUGS
If underlining is present it may be messed up by folding.
BSD
August 2, 2004 BSD