10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I have the input as below:
cat input
032016002 2.891 97.109 16.605 27.172 24.017 32.207 0.233 0.021 39.810 0.077 0.026 19.644 13.882 0.131 11.646 0.102 11.449 76.265 23.735 16.991 83.009 8.840 91.160 0.020 99.980 52.102 47.898 44.004 55.996 39.963 18.625 0.121 1.126 40.189... (15 Replies)
Discussion started by: am24
15 Replies
2. Shell Programming and Scripting
Hello All,
I have a file, but I want to separate the file at a particular record with comma"," in the line
Input file
APPLE6SSAMSUNGS5PRICEPERPIECEDOLLAR600EACH010020340URX581949695US
to
Output file
APPLE6S,SAMSUNGS5,PRICEPERPIECE,DOLLAR600EACH,010020340URX581949695,US
This is for... (11 Replies)
Discussion started by: m6248m
11 Replies
3. UNIX for Dummies Questions & Answers
Here's a sample of the data:
NAME BIRTHDAY SEX LOCATION AGE ID
Jim 05/11/1986 M Japan 27 86
Rei 08/25/1990 F Korea 24 33
Jane 02/24/1985 F India 29 78
I've been trying to sort files using the... (8 Replies)
Discussion started by: maihani
8 Replies
4. Shell Programming and Scripting
Hello, I need to replace newline with tab at certain lines of the file (every four lines is a record).
infile.fq:
@GAIIX-300
ATAGTCAAAT
+
_SZS^\\\cd
@GAIIX-300
CATACGACAT
+
hhghfdffhh
@GAIIX-300
GACGACGTAT
+
gggfcfoutfile:
@GAIIX-300 ATAGTCAAAT + _SZS^\\\cd
@GAIIX-300 ... (6 Replies)
Discussion started by: yifangt
6 Replies
5. UNIX for Dummies Questions & Answers
Hi !
input:
111|222|333|aaa|bbb|ccc
999|888|777|nnn|kkk
444|666|555|eee|ttt|ooo|ppp
With awk, I am trying to change the FS "|" to "; " only from the 4th field until the end (the number of fields vary between records).
In order to get:
111|222|333|aaa; bbb; ccc
999|888|777|nnn; kkk... (1 Reply)
Discussion started by: beca123456
1 Replies
6. Shell Programming and Scripting
Hi all,
How can i convert comma delimited .csv file to tab separate using sed command or script.
Thanks,
Krupa (4 Replies)
Discussion started by: krupasindhu18
4 Replies
7. Shell Programming and Scripting
Hi,
I have a flat file with fields separated by a X'1F'
i have to fetch 4th field from second line.
please help me how to achieve it.
I tried with below command and its not working.
cut -f4 -d`echo -e '\x1f'` filename.txt
I am using SunOS.
Thanks in advance. (2 Replies)
Discussion started by: rohan10k
2 Replies
8. Shell Programming and Scripting
Hi, all
I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes.
sample input:
for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Discussion started by: kevintse
8 Replies
9. Shell Programming and Scripting
I have files with tabs separating the fields but those fields values can have whitespace characters (basically a text string). I want to instruct join to not consider white spaces as separators but only tabs.
I have tried:
join -t "<Tab>" file1 file2
join -t "<tab>" file1 file2
join -t "\t"... (7 Replies)
Discussion started by: FrancoisCN
7 Replies
10. Shell Programming and Scripting
I have some version of AWK that does not support regular expression field separators ( neither do I have nawk or gawk). How do I go about reading a line with the field separator as either the string "=#" or "+=".
My data looks like this:
abhishek=#nnnnn+#1234+#87
One option is to use... (2 Replies)
Discussion started by: Abhishek Ghose
2 Replies
join(1) User Commands join(1)
NAME
join - relational database operator
SYNOPSIS
join [-a filenumber | -v filenumber] [-1 fieldnumber]
[-2 fieldnumber] [-o list] [-e string] [-t char] file1 file2
join [-a filenumber] [-j fieldnumber] [-j1 fieldnumber]
[-j2 fieldnumber] [-o list] [-e string] [-t char] file1 file2
DESCRIPTION
The join command forms, on the standard output, a join of the two relations specified by the lines of file1 and file2.
There is one line in the output for each pair of lines in file1 and file2 that have identical join fields. The output line normally con-
sists of the common field, then the rest of the line from file1, then the rest of the line from file2. This format can be changed by using
the -o option (see below). The -a option can be used to add unmatched lines to the output. The -v option can be used to output only
unmatched lines.
The default input field separators are blank, tab, or new-line. In this case, multiple separators count as one field separator, and leading
separators are ignored. The default output field separator is a blank.
If the input files are not in the appropriate collating sequence, the results are unspecified.
OPTIONS
Some of the options below use the argument filenumber. This argument should be a 1 or a 2 referring to either file1 or file2, respectively.
-a filenumber In addition to the normal output, produce a line for each unpairable line in file filenumber, where filenumber is 1 or
2. If both -a 1 and -a 2 are specified, all unpairable lines will be output.
-e string Replace empty output fields in the list selected by option -o with the string string.
-j fieldnumber Equivalent to -1fieldnumber -2fieldnumber.
-j1 fieldnumber Equivalent to -1fieldnumber.
-j2 fieldnumber Equivalent to -2fieldnumber. Fields are numbered starting with 1.
-o list Each output line includes the fields specified in list. Fields selected by list that do not appear in the input will be
treated as empty output fields. (See the -e option.) Each element of which has the either the form filenumber.fieldnum-
ber, or 0, which represents the join field. The common field is not printed unless specifically requested.
-t char Use character char as a separator. Every appearance of char in a line is significant. The character char is used as the
field separator for both input and output. With this option specified, the collating term should be the same as sort
without the -b option.
-v filenumber Instead of the default output, produce a line only for each unpairable line in filenumber, where filenumber is 1 or 2.
If both -v 1 and -v 2 are specified, all unpairable lines will be output.
-1 fieldnumber Join on the fieldnumberth field of file 1. Fields are decimal integers starting with 1.
-2fieldnumber Join on the fieldnumberth field of file 2. Fields are decimal integers starting with 1.
OPERANDS
The following operands are supported:
file1
file2 A path name of a file to be joined. If either of the file1 or file2 operands is -, the standard input is used in its place.
file1 and file2 must be sorted in increasing collating sequence as determined by LC_COLLATE on the fields on which they are to be joined,
normally the first in each line (see sort(1)).
USAGE
See largefile(5) for the description of the behavior of join when encountering files greater than or equal to 2 Gbyte (2^31 bytes).
EXAMPLES
Example 1 Joining the password file and group file
The following command line will join the password file and the group file, matching on the numeric group ID, and outputting the login name,
the group name and the login directory. It is assumed that the files have been sorted in ASCII collating sequence on the group ID fields.
example% join -j1 4-j2 3 -o 1.1 2.1 1.6 -t:/etc/passwd /etc/group
Example 2 Using the -o option
The -o 0 field essentially selects the union of the join fields. For example, given file phone:
!Name Phone Number
Don +1 123-456-7890
Hal +1 234-567-8901
Yasushi +2 345-678-9012
and file fax:
!Name Fax Number
Don +1 123-456-7899
Keith +1 456-789-0122
Yasushi +2 345-678-9011
where the large expanses of white space are meant to each represent a single tab character), the command:
example% join -t"tab" -a 1 -a 2 -e '(unknown)' -o 0,1.2,2.2 phone fax
would produce
!Name Phone Number Fax Number
Don +1 123-456-7890 +1 123-456-7899
Hal +1 234-567-8901 (unknown
Keith (unknown) +1 456-789-012
Yasushi +2 345-678-9012 +2 345-678-9011
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of join: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, LC_COLLATE, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 All input files were output successfully.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |Enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
awk(1), comm(1), sort(1), uniq(1), attributes(5), environ(5), largefile(5), standards(5)
NOTES
With default field separation, the collating sequence is that of sort -b; with -t, the sequence is that of a plain sort.
The conventions of the join, sort, comm, uniq, and awk commands are wildly incongruous.
SunOS 5.11 8 Feb 2000 join(1)