I have an issue with the below script
It is taking too long to get a string from in1.text, search for the string in in2.txt and create a new file out1.txt.
Is there any alternative way we can achieve the same faster?
Thanks in advance
Moderator's Comments:
Please use CODE tags rather than ICODE tags when displaying code with more than 1 line or with a single line that might be split due to line length.
Last edited by Don Cragun; 08-15-2014 at 09:22 PM..
Reason: Changed ICODE tags to CODE tags.
As I know:
FNR: The ordinal number of the current record in the current file.
NR: The ordinal number of the current record from the start of input.
I don't understand really differency between NR and FNR. Who can explain it for me? And give me an example.
Thanks (1 Reply)
Hi Guys,
I have two files:
f1:
A B C D E F G H
f2:
A X Y Z
f1 has 48000 lines, and f2 has 68. I have been matching f1 $3 to f2 $1, and getting f3:
A A B C D E F G
I would like f3 too look like this:
A X Y Z A B C D E F G (2 Replies)
cat file1
1 a b c
2 d e f
3 a f r
cat file2
a c e
output should be
1
3
means:
if field 1 of file2 matches filed 2 of file1 then print field 1 of file1
I know that it can be done using awk NR=FNR.
But not able to acheive it.
Thanks in advance. (9 Replies)
awk -F'' 'FNR==NR {a=$2; next} {$1=a} 1' $useralias ${entries} >> ${entries}_2
Hi,
Is there anyway to alter this command so that if it does not find a match it will just leave the line alone instead of replacing what it doesn't find with a blank space? (4 Replies)
This has been asked and answered hundreds of times, but I can't understand the syntax of awk's NR==FNR trick for merging files and printing the correct columns.
Here's my File 1
1 rs8179466 224176 A ADD 1037 1.066 0.1421 0.8065 1.408 0.4468 ... (3 Replies)
Hi
i have file1:
conn=232257 client=16218.19488.218.86:51237 protocol=LDAP
file2:
conn=232257 dn="uid=apple,ou=xxxx,ou=usfgfhfers,dc=example,dc=com"
conn=232370 dn="uid=ball,ou=yyyyyy,ou=usfhfhfhers,dc=example,dc=com"
In the output file it should match first column from above both files... (2 Replies)
Example:
$ cat file1
2
3$ cat file2
1
2
3
4
5
6The following awk script works like a charm, NR==FNR is true for file1, the remainder runs for file2:
awk '
NR==FNR {A; next}
($1 in A)
' file1 file2
2
3Now have an empty file1:
>file1and run the awk script again.
The result is empty... (8 Replies)
Hi everybody!
need some awk-support. i want a line-selective printout of a file.
wat i normally will do with ...
awk ' FNR==8' sample.txt
But now i need the data from line 8, 10 and the following data from line13 to 250 wich is not end of the file. I tried allready to combine it but without... (2 Replies)
To merge mutiple *.tab files as:
file1.tab
rs1 A A
rs2 A A
rs3 C C
rs4 C Cfile2.ind
rs1 T T
rs2 T T
rs3 G G
rs4 G Gand file3.tab
rs1 B B
rs2 B B
rs3 L L
rs4 L LOutput:
file1.tab file2.tab file3.tab
AA TT BB
AA TT BB
CC GG LL
CC GG ... (4 Replies)
Dear All,
I have below two files with me:
file 1:
A|B
E|F
C|D
file 2:
A|X|Y
R|T|I
C|V|N
I want to compare 1st column of each file and than print both columns of file 1 and column 2 and 3 of file 2
Sample required output in regards to above files is below:
A|B|X|Y
C|D|V|N (5 Replies)
Discussion started by: Nebula
5 Replies
LEARN ABOUT REDHAT
dos2unix
dos2unix(1) General Commands Manual dos2unix(1)NAME
dos2unix - DOS/MAC to UNIX text file format converter
SYNOPSYS
dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...]
Options:
[-hkqV] [--help] [--keepdate] [--quiet] [--version]
DESCRIPTION
This manual page documents dos2unix, the program that converts plain text files in DOS/MAC format to UNIX format.
OPTIONS
The following options are available:
-h --help
Print online help.
-k --keepdate
Keep the date stamp of output file same as input file.
-q --quiet
Quiet mode. Suppress all warning and messages.
-V --version
Prints version information.
-c --convmode convmode
Sets conversion mode. Simulates dos2unix under SunOS.
-o --oldfile file ...
Old file mode. Convert the file and write output to it. The program default to run in this mode. Wildcard names may be used.
-n --newfile infile outfile ...
New file mode. Convert the infile and write output to outfile. File names must be given in pairs and wildcard names should NOT be
used or you WILL lost your files.
EXAMPLES
Get input from stdin and write output to stdout.
dos2unix
Convert and replace a.txt. Convert and replace b.txt.
dos2unix a.txt b.txt
dos2unix -o a.txt b.txt
Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode. Convert c.txt from Mac to Unix
ascii format.
dos2unix a.txt -c iso b.txt
dos2unix -c ascii a.txt -c iso b.txt
dos2unix -c mac a.txt b.txt
Convert and replace a.txt while keeping original date stamp.
dos2unix -k a.txt
dos2unix -k -o a.txt
Convert a.txt and write to e.txt.
dos2unix -n a.txt e.txt
Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt.
dos2unix -k -n a.txt e.txt
Convert and replace a.txt. Convert b.txt and write to e.txt.
dos2unix a.txt -n b.txt e.txt
dos2unix -o a.txt -n b.txt e.txt
Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt.
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
DIAGNOSTICS BUGS
The program does not work properly under MSDOS in stdio processing mode. If you know why is that so, please tell me.
AUTHORS
Benjamin Lin - <blin@socs.uts.edu.au>
Bernd Johannes Wuebben (mac2unix mode) <wuebben@kde.org>
MISCELLANY
Tested environment:
Linux 1.2.0 with GNU C 2.5.8
SunOS 4.1.3 with GNU C 2.6.3
MS-DOS 6.20 with Borland C++ 4.02
Suggestions and bug reports are welcome.
SEE ALSO unix2dos(1)mac2unix(1)1995.03.31 dos2unix v3.0 dos2unix(1)