Select files for two different directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Select files for two different directory
# 1  
Old 05-09-2013
Select files for two different directory

I have run one file.but this file is two different directory is there.I wrote the if loop but one directory to find it the file and another directory is not find.
Code:
#!bin/bash
a=/tmp
mau="manual.sh"
if [ -s $mau ]
then
echo `ls -l $mau`
else
echo "file not there"
b=/scr #not find the directory
pwd #{o/p=/tmp this cmd not working}
echo `ls -l $mau`
echo "file is there"
else 
echo "file not there"
fi

---------- Post updated at 05:19 PM ---------- Previous update was at 04:45 PM ----------

Quote:
Originally Posted by rajivgandhi
I have run one file.but this file is two different directory is there.I wrote the if loop but one directory to find it the file and another directory is not find.
Code:
#!bin/bash
a=/tmp
mau="manual.sh"
if [ -s $mau ]
then
echo `ls -l $mau`
else
echo "file not there"
b=/scr #not find the directory
pwd #{o/p=/tmp this cmd not working}
echo `ls -l $mau`
echo "file is there"
else 
echo "file not there"
fi

# 2  
Old 05-09-2013
To compare the files in 2 directories in fine, use diff, but for just names, find or ls, sort and comm. The comm tool is a lines in set tool. comm a b reads files a and b, assuming they are binary sorted unique, in sort order, identifying the a only lines, b only lines and both lines. The b only lines get a leading tab, and the both lines get 2 leading tabs, to put them in different columns. You can remove columns, like comm -23 says just a only lines.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Directory containing files,Print names of the files in the directory that are exactly same content.

Given a directory containing say a few thousand files, please output a list of all the names of the files in the directory that are exactly the same, i.e. have the same contents. func(a_directory_name) output -> {“matches”: , ... ]} e.g. func(“/home/my/files”) where the directory... (7 Replies)
Discussion started by: anuragpgtgerman
7 Replies

2. Shell Programming and Scripting

Bash to select oldest folder in directory and write to log

In the bash below the oldest folder in a directory is selected. If there are 3folders in the directory /home/cmccabe/Desktop/NGS/test and nothing is done to them (ie. no files deleted, renamed) then the bash correctly identifies f1 as the oldest. However, if something is done to the folder then... (4 Replies)
Discussion started by: cmccabe
4 Replies

3. Shell Programming and Scripting

Bash to select oldest folder in directory automatically and log process

The `bash` below uses the oldest folder in the specified directory and logs it. The goes though an analysis process and creates a log. My problem is that if there are 3 folders in the directory folder1,folder2,folder3, the bash is using folder2 for the analysis eventhough folder1 is the oldest... (0 Replies)
Discussion started by: cmccabe
0 Replies

4. Shell Programming and Scripting

Bash to select and save file in new directory

I am trying to select a file in bash and save it to a directory. The below does run but no selected file is saved. Thank you :). bash # select file printf "please select a file to analyze with entered gene or genes \n" select file in $(cd... (4 Replies)
Discussion started by: cmccabe
4 Replies

5. Shell Programming and Scripting

Bash to select panel then specific file in directory

I am using bash to prompt a user for a choice using: where a "y" response opens a menu with available panels that can be used. while true; do read -p "Do you want to get coverage of a specific panel?" yn case $yn in * ) menu; break;; * ) exit;; * ) echo... (6 Replies)
Discussion started by: cmccabe
6 Replies

6. Shell Programming and Scripting

How to select all files added to a directory in the past 5 mins (HP-UX)?

Hey everyone, I need to select all files that were added to a specific directory in the past 5 mins and copy them over to a different directory. I am using HP-UX OS which does not have support for amin, cmin, and mmin. B/c of this, I am creating a temp file and will use the find -newer command... (7 Replies)
Discussion started by: mattkoz
7 Replies

7. Shell Programming and Scripting

How to select First two directory in from path name?

Can somebody help me on below question I have path and i want to select first two directory name in variable how we can do this. /Myname/xyz/yourname/abc/somebodyname i want to select /Myname/xyz in variable. Quick help will be appriciated. Thanks in advance Regards, Kumar (10 Replies)
Discussion started by: yadavricky
10 Replies

8. UNIX for Dummies Questions & Answers

Select files and move them!

Hello everyone, I'm new a to Linux command line. I was executing some commands to the data i have when i faced this problem. I have a directory contanining thousands of files inside, with many many different names. I wanted to pick the FILENAMES that contains '-1.mol' in thier name, and... (2 Replies)
Discussion started by: Error404
2 Replies

9. Shell Programming and Scripting

Need script to select multiple files from archive directory based on the date range

hi all, here is the description to my problem. input parameters: $date1 & $date2 based on the range i need to select the archived files from the archived directory and moved them in to working directory. can u please help me in writing the code to select the multiple files based on the... (3 Replies)
Discussion started by: bbc17484
3 Replies

10. Shell Programming and Scripting

How to select the *.txt files using Loops

Hi, I need to select the txt files from one folder and pass this filename as parameter and the loop should discontinue after all the files are selected and the iteration should continue only once.. Viz., i have files like abc_2005_f1.txt, abc_2006_f1.txt, abc_2007_f1.txt... in /data... (11 Replies)
Discussion started by: kumar16
11 Replies
Login or Register to Ask a Question