11-14-2012
danielos,
I am aware that $0 was the entire line, I used $NF though and it gave me the length of the last column.
Alistar,
That sounds like a good plan, I'll give that a shot!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Dear All,
To find the length of the longest line from a file i have used wc -L which is giving the proper output...
But the problem is AIX os does not support wc -L command.
so is there any other way 2 to find out the length of the longest line using awk or sed ?
Regards,
Pankaj (1 Reply)
Discussion started by: panknil
1 Replies
2. Shell Programming and Scripting
I will be performing a task on several directories, each containing a large number of files (2500+) that follow a regular naming convention:
YYYY_MM_DD_XX.foo_bar.A.B.some_different_stuff.EXT
What I would like to do is automatically discover the part of the filenames that are common to all... (1 Reply)
Discussion started by: cmcnorgan
1 Replies
3. Shell Programming and Scripting
Hi,
I have a fixed length file where I need to verify the values of 3 different fields, where each field will have a different value.
How can I do that in a single step. (6 Replies)
Discussion started by: naveen_sangam
6 Replies
4. UNIX for Dummies Questions & Answers
Hii i have a file with data as shown below. Here i need to remove duplicates of the rows in such a way that
it just checks for 2,3,4,5 column for duplicates.When deleting duplicates,retain largest row i.e with many columns with values should be selected.Then it must remove duplicates such that by... (11 Replies)
Discussion started by: reva
11 Replies
5. Shell Programming and Scripting
Good Morning/Afternoon All,
I am using the nawk utility in korn shell to find the longest field and display that result.
My Data is as follows:
The cat ran
The elephant ran
Milly ran too
We all ran
I have tried nawk '{ if (length($1) > len) len=length($1); print $1}' filename
The... (5 Replies)
Discussion started by: SEinT
5 Replies
6. UNIX for Dummies Questions & Answers
Hi Guys,
I was going some trial and error to see if I can find the longest word in a text.
I was using Pipes because they are easier to use in this case.
I was stuck on this for a while so I thought I'll get some help with it.
I tried this code to separate all the words in a text in... (4 Replies)
Discussion started by: bawse.c
4 Replies
7. Shell Programming and Scripting
I would be grateful if someone could help me. I am trying to write a .sh script in UNIX.
I have the following code;
User=john
User=james
User=ian
User=martin
for x in ${User}
do
print ${#x}
done
This produces the following output;
4
5
3
6 (12 Replies)
Discussion started by: mmab
12 Replies
8. Shell Programming and Scripting
Hi ,
I need to extract data from below mentioned data, having no delimiter and havin no fixed column length.
For example:
Member nbr Ref no date
10000 1000 10202012
200000 2000 11202012
Output:
to update DB with memeber nbr on basis of ref no.
... (6 Replies)
Discussion started by: ns64110
6 Replies
9. Shell Programming and Scripting
I met a challenge to filter ~70 millions of sequence rows and I want using awk with conditions:
1) longest string of each pattern in column 2, ignore any sub-string, as the index;
2) all the unique patterns after 1);
3) print the whole row;
input:
1 ABCDEFGHI longest_sequence1
2 ABCDEFGH... (12 Replies)
Discussion started by: yifangt
12 Replies
10. Shell Programming and Scripting
Running below line gives 3957 as length of longest line in file 20121119_SRMNotes_init.dat
awk ' { if ( length > 3950 ) { x = length } }END{ print x }' 20121119_SRMNotes_init.dat
While wc -L 20121119_SRMNotes_init.dat gives output as 4329. Why is there a difference between these two commands.... (2 Replies)
Discussion started by: Satish Mantha
2 Replies
PSC(1) General Commands Manual PSC(1)
NAME
psc - prepare sc files
SYNOPSIS
psc [-fLkrSPv] [-s cell] [-R n] [-C n] [-n n] [-d c]
DESCRIPTION
Psc is used to prepare data for input to the spreadsheet calculator sc(1). It accepts normal ascii data on standard input. Standard out-
put is a sc file. With no options, psc starts the spreadsheet in cell A0. Strings are right justified. All data on a line is entered on
the same row; new input lines cause the output row number to increment by one. The default delimiters are tab and space. The column for-
mats are set to one larger than the number of columns required to hold the largest value in the column.
OPTIONS
-f Omit column width calculations. This option is for preparing data to be merged with an existing spreadsheet. If the option is not
specified, the column widths calculated for the data read by psc will override those already set in the existing spreadsheet.
-L Left justify strings.
-k Keep all delimiters. This option causes the output cell to change on each new delimiter encountered in the input stream. The
default action is to condense multiple delimiters to one, so that the cell only changes once per input data item.
-r Output the data by row first then column. For input consisting of a single column, this option will result in output of one row
with multiple columns instead of a single column spreadsheet.
-s cell
Start the top left corner of the spreadsheet in cell. For example, -s B33 will arrange the output data so that the spreadsheet
starts in column B, row 33.
-R n Increment by n on each new output row.
-C n Increment by n on each new output column.
-n n Output n rows before advancing to the next column. This option is used when the input is arranged in a single column and the
spreadsheet is to have multiple columns, each of which is to be length n.
-d c Use the single character c as the delimiter between input fields.
-P Plain numbers only. A field is a number only when there is no imbedded [-+eE].
-S All numbers are strings.
-v Print the version of psc
SEE ALSO
sc(1)
AUTHOR
Robert Bond
PSC 7.16 19 September 2002 PSC(1)