05-06-2018
I think you want $i not $1 in the sed expression.
Then, it is unprecise: a grep is searched in the whole line, can match on the wrong side. Can be improved by boundaries e.g. grep "^$i," file1.txt.
Last but not least, the files are read very often. It makes sense to look for more efficient solutions!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I want to replace the content in 3rd column in the first file by the line in the 2nd file (a list) if matches with 1st column of 2nd file. There are many 1st files in different directories:
File1
172.27.1.15 222 I_J_Mar_Sci_34_27.pdf
172.27.28.1 489 Sci_Cult_71_60.pdf... (3 Replies)
Discussion started by: srsahu75
3 Replies
2. Shell Programming and Scripting
I have a large file that looks like the below output:
system SUNWxwmod X Window System kernel modules
system SUNWxwoft X Window System optional fonts
system SUNWxwopt X Window System Optional Clients
system ... (1 Reply)
Discussion started by: hxman
1 Replies
3. Shell Programming and Scripting
So far I have this little regex to match sessionids:
session.id={32}What must I add to make it match all occurances i want to match?session_id=993e3cf23ffff68a2b619518829192b9
?session_id=993e3cf23ffff68a2b619518829192b9
&session_id=993e3cf23ffff68a2b619518829192b9... (1 Reply)
Discussion started by: lowmaster
1 Replies
4. Shell Programming and Scripting
Hi all,
Greetings,
I have the following scenario, The contents of main file are like :
Unix|||||forum|||||||||||||||is||||||the||best
so||||||be|||||on||||||||||||||||||||||||||||||||||||||||||||it
And i need the output in the following form:
Unix=forum=is=the=best
so=be=on=it
... (3 Replies)
Discussion started by: dipanchandra
3 Replies
5. Shell Programming and Scripting
Hi,
I have a file with 2500 entries. There are many duplicates,triplicates symbols in my file in the first column and the second column has categories(high/medium/low) . I want to have count for the occurances of each category for each unique symbol
ABC high
ABC high
ABC medium
ABC ... (2 Replies)
Discussion started by: Diya123
2 Replies
6. Shell Programming and Scripting
Input file
data20714 7327 7366 detail
data20714 7327 7366 main
data250821 56532 57634 detail
data250821 57527 57634 main
data250821 57359 57474 main
data250821 57212 57301 main
data250821 57140 57159 detail
data250821 56834 57082 main
data250821 56708 56779 main ... (3 Replies)
Discussion started by: perl_beginner
3 Replies
7. Shell Programming and Scripting
I have some text files as shown below. I would like to add the values of each string. Your help would be appreciated!!
file1.txt
SUS 2
PRS 2
ALI 1
PRS 1
GLK 2
file2.txt
PRS 3
GLK 6
SUS 18
Desired output
SUS 20
PRS 6 (2 Replies)
Discussion started by: arch
2 Replies
8. Shell Programming and Scripting
Trying to match $2 in original_targets with $2 of new_targets . If the two numbers match exactly then a match.txt file is outputted using the information in the new_targets in the beginning 4 fields $1, $2, $3, $4 and value of $4 in the original_targets . If there is "No Match" then a no... (2 Replies)
Discussion started by: cmccabe
2 Replies
9. Shell Programming and Scripting
I have a test file a.txt
001 123 456 789
002 This is just a
001 test data
003 file.
I want to clear columns 5 and 6 if the first 3 characters are 001 using awk.
I tried following but does not work. Any suggestions?
awk 'BEGIN{OFS=FS=""} {if (substr($0,1,3)=="123") $5=" "; $6="... (20 Replies)
Discussion started by: Soham
20 Replies
10. UNIX for Beginners Questions & Answers
Hi,
i have 2 files , the data i need to match is in masterfile and i need to pull out column 3 from master if column 1 and 2 match and output entire row to new file
I have tried with join and awk and i keep getting blank outputs or same file
is there an easier way than what i am... (4 Replies)
Discussion started by: axis88
4 Replies
LEARN ABOUT SUSE
cabextract
CABEXTRACT(1) General Commands Manual CABEXTRACT(1)
NAME
cabextract - program to extract files from Microsoft cabinet (.cab) archives
SYNOPSIS
cabextract [-ddir] [-f] [-Fpattern] [-h] [-l] [-L] [-p] [-q] [-s] [-t] [-v] cabinet files ...
DESCRIPTION
cabextract is a program that un-archives files in the Microsoft cabinet file format (.cab) or any binary file which contains an embedded
cabinet file (frequently found in .exe files).
cabextract will extract all files from all cabinet files specified on the command line.
To extract a multi-part cabinet consisting of several files, only the first cabinet file needs to be given as an argument to cabextract as
it will automatically look for the remaining files. To prevent cabextract from extracting cabinet files you did not specify, use the -s
option.
OPTIONS
A summary of options is included below.
-d dir Extracts all files into the directory dir.
-f When testing or extracting cabinet files, corrupted MSZIP blocks will be ignored. A warning will be printed if a corrupted MSZIP
block is encountered.
-F pattern
Only files with names that match the shell pattern pattern shall be listed, tested or extracted. On non-GNU systems, this match may
be case-sensitive.
-h Prints a page of help and exits.
-l Lists the contents of the given cabinet files, rather than extracting them.
-L When extracting cabinet files, makes each extracted file's name lowercase.
-p Files shall be extracted to standard output.
-q When extracting cabinet files, suppresses all messages except errors and warnings.
-s When testing, listing or extracting cabinets which span multiple files, only cabinet files given on the command line shall be used.
-t Tests the integrity of the cabinet. Files are decompressed, but not written to disk or standard output. If the file successfully
decompresses, the MD5 checksum of the file is printed.
-v If given alone on the command line, prints the version of cabextract and exits. Given with a list of cabinet files, it will list the
contents of the cabinet files.
AUTHOR
This manual page was written by Stuart Caie <kyzer@4u.net>, based on the one written by Eric Sharkey <sharkey@debian.org>, for the Debian
GNU/Linux system.
October 30, 2005 CABEXTRACT(1)