Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Bash selection of files with similar name Post 303041481 by ALou on Monday 25th of November 2019 01:09:22 PM
Old 11-25-2019
Bash selection of files with similar name

Hi all,
This is my first day on Linux shell!!!

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....
Code:
#!/bin/bash

file1_path="~/All_files/"
var1=S*R1.fastq.gz
echo $var1 

file2_path="~/All_files/"
var2=S*R2.fastq.gz  
echo $var2


if ["${VAR1:0:18}" = "${VAR2:0:18}"] ; then


Moderator's Comments:
Mod Comment
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.

Last edited by rbatte1; 12-02-2019 at 10:53 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

selection of files based on its types

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)
Discussion started by: ganapati
3 Replies

2. Shell Programming and Scripting

selection of context in files

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)
Discussion started by: manas_ranjan
1 Replies

3. Shell Programming and Scripting

Paging/Scrolling a List of files for selection

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)
Discussion started by: Festus Hagen
5 Replies

4. Shell Programming and Scripting

compare the similar files

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)
Discussion started by: rdcwayx
2 Replies

5. UNIX for Dummies Questions & Answers

Merge two files with two columns being similar

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)
Discussion started by: Atrisa
9 Replies

6. Shell Programming and Scripting

Looking to find files that are similar.

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)
Discussion started by: jeffs42885
5 Replies

7. UNIX for Dummies Questions & Answers

Finding similar strings between two files

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)
Discussion started by: a_bahreini
7 Replies

8. Shell Programming and Scripting

Yes or No selection within bash function

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)
Discussion started by: cmccabe
5 Replies

9. Shell Programming and Scripting

Bash/shell merge similar lines

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)
Discussion started by: umang2382
2 Replies

10. Solaris

Getting similar lines in two files

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)
Discussion started by: anaigini45
1 Replies
srf2fastq(1)							   Staden io_lib						      srf2fastq(1)

NAME
srf2fastq - Converts SRF files to Sanger fastq format SYNOPSIS
srf2fastq [options] srf_archive ... DESCRIPTION
srf2fastq extracts sequences and qualities from one or more SRF archives and writes them in Sanger fastq format to stdout. Note that Illumina also have a fastq format (used in the GERALD directories) which differs slightly in the use of log-odds scores for the quality values. The format described here is using the traditional Phred style of quality encoding. OPTIONS
-c Outputs calibrated confidence values using the ZTR CNF1 chunk type for a single quality per base. Without this use the original Illumina _prb.txt files consisting of four quality values per base, stored in the ZTR CNF4 chunks. -C Masks out sequences tagged as bad quality. -s root Generates files on disk with filenames starting root, one file per non-explicit element in the SRF/ZTR region (REGN) chunk. Typi- cally this results in two files for paired end runs. The filename suffixes come from the names listed in the SRF region chunks. This option conflicts with the -S parameter. -S Splits sequences into regions, but sequentially lists each sequence region to stdout instead of splitting to separate files on disk. This option conflicts with the -s parameter. -n When using -s the filename suffixes are simply numbered (starting with 1) instead of using the names listed in the SRF region chunks. -a Appends region index to the sequence names. Ie generate "name/1" and "name/2" for a paired read. -e Include any explicit sequence (ZTR region chunk of type 'E') in the sequence output. The explicit sequence is also included in the quality line too. Currently this is utilised by ABI SOLiD to store the last base of the primer. -r region list Reverse complements the sequence and reverses the quality values for all regions in the region list. This is a comma separated list of integer values enumerating the regions, starting from 1. Note that this option only works when either -s or -S are specified. EXAMPLES
To extract only the good quality sequences from all srf files in the current directory using calibrated confidence values (if available). srf2fastq -c -C *.srf > runX.fastq To extract a paired end run into two separate files with sequences named name/1 and name/2. srf2fastq -s runX -a -n runX.srf To extract a paired end run as a single file, alternating forward and reverse sequences, with the second read being reverse complemented. srf2fastq -S -r 2 runX.srf > runX.fastq AUTHOR
James Bonfield, Steven Leonard - Wellcome Trust Sanger Institute December 10 srf2fastq(1)
All times are GMT -4. The time now is 06:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy