So, I am trying to write a script that that will pick up pairs of files with the same name (not the same content) but that are different in one character (one is *R1 the other is *R2)...
Something like: look ate the files, whenever they are the same except in the R1/R2, than run ...
The if that I tried is I think is going into the the file content rather than the name....
Did this make any sense?
Thanks a lot.
This is what I was able to do so far....
Moderator's Comments:
Please wrap all code, files, input & output/errors in CODE tags.
It makes it far easier to read and preserves spaces for indenting and/or fixed-width data.
Welcome to the forum, firstly some housekeeping
...
To keep the forums high quality for all users, please take the time to format your posts correctly.
First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)
Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.
Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.
Thank You.
The UNIX and Linux Forums
...
The variables var1 and var2 actually contain the literal strings you have assigned to them (i.e S*R1.fastq.gz and S*R2.fastq.gz) these are expanded by the shell when they are build into the echo command. To demonstrate:
See how using double quotes protects the string from being expanded by the shell. You could do something like this to have the shell expand the wildcard: --- Post updated at 08:13 AM ---
One approach to this problem is to populate an array with the expanded filenames and then step thru it comparing with the next entry like this:
Last edited by Chubler_XL; 11-25-2019 at 05:27 PM..
Reason: Updated search/replace to avoid matching on R1 in early part of filename
These 2 Users Gave Thanks to Chubler_XL For This Post:
Thank you very much for the help.
I am sorry about missing out on the rules of posting. I just focused on the "no smoking"one!!!
I am missing out on a lot!!!!! I have found a few but do you have any recommendation on a website that can take me step by step on programming on unix?
I pretty much learnt awk programming from this site . Initially I was amazed how easily awk could be used to solve problems posted here. I worked thru the solutions proposed by others and used google and other on-line resources to nut out what was going on. I did start with a lot of programming experience in other languages, which gave me a head start. Start by understanding the supplied solutions and work up to figuring out your own answers without looking at how others have done it first. Compare what you have come up with to the supplied answer. It's fairly important that you have access to a system you can trial and debug solutions on.
Hi,
I need to compare the /etc/passwd files from 2 servers, and extract the users that are similar in these two files. I sorted the 2 files based on the user IDs (UID) (3rd column). I first sorted the files using the username (1st column), however when I use comm to compare the files there is no... (1 Reply)
Hello,
I've been working on a bash script to parse through firewall logs (cisco). I'm nearing the end and have a dilemma.
My data looks as such (actual data is several gigs worth of logs - without the headers):
sourceIP destinationIP destinationProtocol destinationPort
1.1.1.1 2.2.2.2 ... (2 Replies)
I need to add a selection within the bash function below and am having some trouble doing so.
phox2b() {
printf "\n\n"
printf "What is the id of the patient getting Phox2B analysis : "; read id
printf "Is this an intronic variant? Y/N "; read match_choice
case... (5 Replies)
Hi,
I have a file1 like this:
ABAT
ABCA1
ABCC1
ABCC5
ABCC8
ABCE1
ABHD2
ABL1
CAMTA1
ACBD3
ACCN1
And I have a second file like this:
chr19 46118590 46119564 MACS_peak_1499 3100.00 chr19 46122009 46148405 CYP2B7P1 -2445
chr1 7430312 7430990... (7 Replies)
Hello all,
I have a server that is running AIX, running a tool that converts various printstreams (AFP/Metadata) to PDF. This is done using a rexx script and an off the shelf utility.
Each report (there's around 125) uses a certain script file, it's basically a text file.
I am trying... (5 Replies)
Hi everyone. How can I merge two files, where each file has 2 columns and the first columns in both files are similar? I want all in a file of 4 columns; join command removes the duplicate columns.
1 Dave
2 Mark
3 Paul
1 Apple
2 Orange
3 Grapes
to get it like this in the 3rd file:... (9 Replies)
I got many pair files, which only have small difference, such as more space, or more empty line, and some unreadable characters.
If list by commend "diff", I can see many many difference.
So I'd like to write a script to compare the pair files, if 95% contents are same, I will think they are... (2 Replies)
Hi All,
I have the following script and would like to add page up and down functionality to be able to stroll through the list.
Is this possible?
If so, Any pointers to examples, info, tips, suggestions would be appreciated.
BTW, Any suggestion for better practices on the following code... (5 Replies)
I have a file like this
QUEUE: <ITEM(69)> "/NLA///ACHO_EQU_IDX"
Q_KEY: <ITEM(69)> "/NLA///ACHO_EQU_IDX"
Q_TYPE: <VSTR(32)> "GEN_VSTR_INDEX"
... (1 Reply)
Daily we are getting some datafiles to our unix server location FTPIN.
Incoming File names will be present in the location "/xyz/test/" as below:
"infile_A1_YYYYMMDD",
"infile_A2_YYYYMMDD",
"infile_B1_YYYYMMDD",
"infile_C1_YYYYMMDD"
"infile_C2_YYYYMMDD"
Where A, B and C are the... (3 Replies)