Sponsored Content
Top Forums Shell Programming and Scripting How to use FS for mixed file? Post 302777797 by Akshay Hegde on Friday 8th of March 2013 11:42:30 AM
Old 03-08-2013
How to use FS for mixed file?

Hi! All

I am just wondering solution to use FS if file fields are separated by whitespace (one or more spaces ), tab and comma, How to use FS ?

finally I want to print all columns as tab separated

look at my file here tagged


Code:
130, US  121337   30.530   -58.900 1941  1 25 19.50  4183107   17,60.0,(2),[00],19.900,(3),[00]
130, US  121337   30.530   -58.900 1941  1 25 19.50  4183107   17,65.0,(2),[00],19.900,(3),[00]
130, US  121337   30.530   -58.900 1941  1 25 19.50  4183107   17,70.0,(2),[00],19.800,(3),[00]
130, US  121337   30.530   -58.900 1941  1 25 19.50  4183107   17,75.0,(2),[00],19.700,(3),[00]
130, US  121337   30.530   -58.900 1941  1 25 19.50  4183107   17,80.0,(2),[00],19.600,(3),[00]
131, US  121337   30.570   -58.970 1941  1 25 19.00  4183108   25,0.0,(1),[00],20.300,(3),[00]
131, US  121337   30.570   -58.970 1941  1 25 19.00  4183108   25,5.0,(1),[00],20.300,(3),[00]
131, US  121337   30.570   -58.970 1941  1 25 19.00  4183108   25,10.0,(2),[00],20.400,(3),[00]

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

output only numbers from mixed string

it must be late because I'm sure this is an easy task with grep sed or awk string would be anything mixing numbers letters and ) ( = output I need is just the numbers... but I just can't seem to get it to work. Any tips would be great :) (10 Replies)
Discussion started by: nortypig
10 Replies

2. Shell Programming and Scripting

Problems using multipart/mixed

Hi all I'm having trouble using MIME's multipart/mixed content type. I just try to send an email with a common body text together with an attachment (.gif). The only output I get is an empty email with no text and an invalid attachment (MS Outlook says it doesn't recognize the attachment type).... (2 Replies)
Discussion started by: Indalecio
2 Replies

3. Shell Programming and Scripting

How do I compare mixed variables?

Searched all over can't figure out how to compare variables of alpha and numeric characters. Example a script that ask user to enter a password and then ask to repeat the password. (6 Replies)
Discussion started by: monx
6 Replies

4. Shell Programming and Scripting

mixed pattern match

I need to grep out patterns that matches the following. 1SR2kW-0003XW-8L Ie a pattern that contain 16 characters and will always be in the same pattern. 6 character, then a -, then 6 character, then a - then 2 character. I need a way to grep out like we grep out IP address. Here there are... (4 Replies)
Discussion started by: anil510
4 Replies

5. Shell Programming and Scripting

PERL - Variable values getting mixed up!

Hi, I only dip my toe into PERL programming on the odd ocassion so I was wondering if anyone had any ideas as to why the below is happening: When I run my PERL script the variable values seem to get mixed up. my $fileName = basename($maxFile,".TXT"); my $currentSeqNum =... (2 Replies)
Discussion started by: chris01010
2 Replies

6. Shell Programming and Scripting

Sorting mixed numbers and letters

Hello, I have a file such as this: chr1 chr2 chr1 chr2 chr3 chr10 chr4 chr5 chrz chr1AI want to sort it, I use this command: sort -k1 -th -n testfilebut I get this output, how can I fix this? chr1 chr1 chr10 chr1A chr2 chr2 (3 Replies)
Discussion started by: Homa
3 Replies

7. Shell Programming and Scripting

awk - mixed for and if to select particular lines in a data file

Hi all, I am new to AWK and I am trying to solve a problem that is probably easy for an expert. Suppose I have the following data file input.txt: 20 35 43 20 23 54 20 62 21 20.5 43 12 20.5 33 11 20.5 89 87 21 33 20 21 22 21 21 56 87 I want to select from all lines having the... (4 Replies)
Discussion started by: naska
4 Replies

8. UNIX for Advanced & Expert Users

Sort mixed data file

I have a text file and each field is separated by semicolon ( ; ). Field number 7 is internally separated by comma ( , ) and pipe ( | ) symbol. I want to sort file based on three different fields which are marked in BOLD. Here first BOLD field will have numbers upto the length of 9 characters,... (6 Replies)
Discussion started by: jnrohit2k
6 Replies

9. Shell Programming and Scripting

Using awk to parse a file with mixed formats in columns

Greetings I have a file formatted like this: rhino grey weight=1003;height=231;class=heaviest;histology=9,0,0,8 bird white weight=23;height=88;class=light;histology=7,5,1,0,0 turtle green weight=40;height=9;class=light;histology=6,0,2,0... (2 Replies)
Discussion started by: Twinklefingers
2 Replies
cut(1)							      General Commands Manual							    cut(1)

Name
       cut - cut out selected fields of each line of a file

Syntax
       cut -clist [file1 file2...]
       cut -flist [-dchar] [-s] [file1 file2...]

Description
       Use  the  command to cut out columns from a table or fields from each line of a file.  The fields as specified by list can be fixed length,
       that is, character positions as on a punched card (-c option), or the length can vary from line to line and be marked with a  field  delim-
       iter character like tab (-f option).  The command can be used as a filter.  If no files are given, the standard input is used.

       Use to make horizontal ``cuts'' (by context) through a file, or to put files together in columns.  To reorder columns in a table, use and

Options
       list	   Specifies  ranges  that must be a comma-separated list of integer field numbers in increasing order.  With optional - indicates
		   ranges as in the -o option of nroff/troff for page ranges; for example, 1,4,7; 1-3,8; -5,10 (short for 1-5,10);  or	3-  (short
		   for third through last field).

       -clist	   Specifies character positions to be cut out.  For example, -c1-72 would pass the first 72 characters of each line.

       -flist	   Specifies  the  fields  to be cut out.  For example, -f1,7 copies the first and seventh field only.	Lines with no field delim-
		   iters are passed through intact (useful for table subheadings), unless -s is specified.

       -dchar	   Uses the specified character as the field delimiter.  Default is tab.  Space or other characters with special  meaning  to  the
		   shell must be quoted.  The -d option is used only in combination with the -f option, according to XPG3 and SVID2/SVID3.

       -s	   Suppresses  lines  with  no	delimiter  characters.	 Unless  specified, lines with no delimiters are passed through untouched.
		   Either the -c or -f option must be specified.

Examples
       Mapping of user IDs to names:
       cut -d: -f1,5 /etc/passwd
       To set name to the current login name for the csh shell:
       set name=`who am i | cut -f1 -d" "`
       To set name to the current login name for the sh, sh5, and ksh shells:
       name=`who am i | cut -f1 -d" "`

Diagnostics
       "line too long"	   A line can have no more than 511 characters or fields.

       "bad list for c/f option"
			   Missing -c or -f option or incorrectly specified list.  No error occurs if a line has fewer fields than the list  calls
			   for.

       "no fields"	   The list is empty.

See Also
       grep(1), paste(1)

																	    cut(1)
All times are GMT -4. The time now is 03:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy