Looping through contents of a file and finding it in different directory The 2019 Stack...

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

A word that means fill it to the required quantity

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

If a sorcerer casts the Banishment spell on a PC while in Avernus, does the PC return to their home plane?

Why not take a picture of a closer black hole?

Why couldn't they take pictures of a closer black hole?

Are spiders unable to hurt humans, especially very small spiders?

What is this business jet?

How come people say “Would of”?

Did any laptop computers have a built-in 5 1/4 inch floppy drive?

Is Cinnamon a desktop environment or a window manager? (Or both?)

How to translate "being like"?

Falsification in Math vs Science

"as much details as you can remember"

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

Does adding complexity mean a more secure cipher?

What information about me do stores get via my credit card?

Correct punctuation for showing a character's confusion

Are turbopumps lubricated?

Ubuntu Server install with full GUI

Is it okay to consider publishing in my first year of PhD?

What is the meaning of Triage in Cybersec world?

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

Kerning for subscripts of sigma?



Looping through contents of a file and finding it in different directory



The 2019 Stack Overflow Developer Survey Results Are InUnderstanding “IFS= read -r line”How can I cat the contents of files found using find into a single file?What is wrong with my init.d script [Segmentation fault]What is the best way to delete files & folders in a directory excluding the contents of one folder?how do I extract the SubDir name 4 deep & put into a Var 4 later use?Looping through lines in file using bash and passing to variable. Resulting variable is not the same value as file, why?Preform operation in bash only if a variable is less than a second variableDynamic Functionfinding a way to wait for an unknown named file to appear in a directory and then doing something with itScript not correctly printing the correct elements of the arraymove file after validation





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I need to compare the contents of a file located in dir A with actual files in different directory. ex- directory A has a file test.txt , Item mentioned in test.txt and not present in directory B should be highlighted. im doing something like this but not working.. it is only searching last word from the file test.txt



#!/bin/sh
IFS=$'n' dirA=$1 dirB=$2
for x in $(cat < "$1"); do base_name="${x##/}"
set -- "$dirB"/"$base_name"*
if [ -e "$1" ]; then
for y; do
echo "$base_name found in B as ${y##*/}" done
else
echo "$x not found in B" fi done.









share|improve this question









New contributor




Roopak Murty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • I tested this program in my cygwin environment. It works well! Maybe it's bash setting problem?

    – JinChin
    13 hours ago











  • @JinChin Notice that the user is not executing this with bash, and that the code does not include anything that is specific to that shell.

    – Kusalananda
    13 hours ago




















0















I need to compare the contents of a file located in dir A with actual files in different directory. ex- directory A has a file test.txt , Item mentioned in test.txt and not present in directory B should be highlighted. im doing something like this but not working.. it is only searching last word from the file test.txt



#!/bin/sh
IFS=$'n' dirA=$1 dirB=$2
for x in $(cat < "$1"); do base_name="${x##/}"
set -- "$dirB"/"$base_name"*
if [ -e "$1" ]; then
for y; do
echo "$base_name found in B as ${y##*/}" done
else
echo "$x not found in B" fi done.









share|improve this question









New contributor




Roopak Murty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • I tested this program in my cygwin environment. It works well! Maybe it's bash setting problem?

    – JinChin
    13 hours ago











  • @JinChin Notice that the user is not executing this with bash, and that the code does not include anything that is specific to that shell.

    – Kusalananda
    13 hours ago
















0












0








0








I need to compare the contents of a file located in dir A with actual files in different directory. ex- directory A has a file test.txt , Item mentioned in test.txt and not present in directory B should be highlighted. im doing something like this but not working.. it is only searching last word from the file test.txt



#!/bin/sh
IFS=$'n' dirA=$1 dirB=$2
for x in $(cat < "$1"); do base_name="${x##/}"
set -- "$dirB"/"$base_name"*
if [ -e "$1" ]; then
for y; do
echo "$base_name found in B as ${y##*/}" done
else
echo "$x not found in B" fi done.









share|improve this question









New contributor




Roopak Murty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I need to compare the contents of a file located in dir A with actual files in different directory. ex- directory A has a file test.txt , Item mentioned in test.txt and not present in directory B should be highlighted. im doing something like this but not working.. it is only searching last word from the file test.txt



#!/bin/sh
IFS=$'n' dirA=$1 dirB=$2
for x in $(cat < "$1"); do base_name="${x##/}"
set -- "$dirB"/"$base_name"*
if [ -e "$1" ]; then
for y; do
echo "$base_name found in B as ${y##*/}" done
else
echo "$x not found in B" fi done.






shell-script






share|improve this question









New contributor




Roopak Murty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Roopak Murty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 14 hours ago









Kusalananda

141k17263439




141k17263439






New contributor




Roopak Murty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 14 hours ago









Roopak MurtyRoopak Murty

1




1




New contributor




Roopak Murty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Roopak Murty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Roopak Murty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • I tested this program in my cygwin environment. It works well! Maybe it's bash setting problem?

    – JinChin
    13 hours ago











  • @JinChin Notice that the user is not executing this with bash, and that the code does not include anything that is specific to that shell.

    – Kusalananda
    13 hours ago





















  • I tested this program in my cygwin environment. It works well! Maybe it's bash setting problem?

    – JinChin
    13 hours ago











  • @JinChin Notice that the user is not executing this with bash, and that the code does not include anything that is specific to that shell.

    – Kusalananda
    13 hours ago



















I tested this program in my cygwin environment. It works well! Maybe it's bash setting problem?

– JinChin
13 hours ago





I tested this program in my cygwin environment. It works well! Maybe it's bash setting problem?

– JinChin
13 hours ago













@JinChin Notice that the user is not executing this with bash, and that the code does not include anything that is specific to that shell.

– Kusalananda
13 hours ago







@JinChin Notice that the user is not executing this with bash, and that the code does not include anything that is specific to that shell.

– Kusalananda
13 hours ago












2 Answers
2






active

oldest

votes


















0














Using diff may do the trick



diff -crs Dir1 Dir2


It will show you if the files are existing, same or different



with a grep on filename might be what you are looking for






share|improve this answer








New contributor




PhLinuX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • The idea seems to be to verify some sort of manifest over files that are supposed to exist, not to compare two directories.

    – Kusalananda
    14 hours ago











  • i want to check file contents in another directory. example file 1 (located in /user/home) has a,b,c so i need to check if a,b,c is present as files in different folder (/etc)

    – Roopak Murty
    14 hours ago











  • @Kusalananda , yes that is correct, l'm looking for manifest over files that are supposed to exist

    – Roopak Murty
    14 hours ago











  • Ok, sorry, may be read a bit too fast. In that case you could use diff -crs ./file /path_to_file/DIr It also show you where are the differences

    – PhLinuX
    13 hours ago



















0














#!/bin/sh

manifest=$1
topdir=$2

while IFS= read -r name; do
pathname="$topdir/$name"

if [ -e "$pathname" ]; then
printf 'Found: %sn' "$pathname" >&2
else
printf 'Not found: %sn' "$pathname" >&2
fi
done <"$manifest"


This script takes a manifest file as its first command line argument, and some directory path as its second argument.



It reads lines from the manifest and tests to see if the pathnames corresponding to those lines exists under the given directory.



Would you only want to test the base name of each name read from the file, then use



#!/bin/sh

manifest=$1
topdir=$2

while IFS= read -r name; do
pathname="$topdir/$( basename "$name" )"

if [ -e "$pathname" ]; then
printf 'Found: %sn' "$pathname" >&2
else
printf 'Not found: %sn' "$pathname" >&2
fi
done <"$manifest"


Related:




  • Understanding "IFS= read -r line"






share|improve this answer
























  • what is pathname="$topdir/$( basename "$name" )" in the above code.. it is showing opposite result Not found:/Users/dir2/a Not found: /Users/dir2/b Not found: /Users/dir2/c , but a ,b, c are present in dir2 as txt files.

    – Roopak Murty
    13 hours ago











  • @RoopakMurty The line creates a new value that is the directory path that is was given followed by the base name of the line read from the file. If the script says that /Users/dir2/a does not exist, well, then that pathname does not exist. The type of file is not taken into consideration. If you could describe a bit more, then maybe I would understand what you mean.

    – Kusalananda
    13 hours ago













  • @RoopakMurty Are you saying that /Users/dir2/a exists? Do you have spaces at the end of the lines in the file that you pass to the script? In that case, delete those spaces.

    – Kusalananda
    13 hours ago













  • yes a is a text file under /Users/dir2 that exists, actually I'm using git bash in windows to run this script, is this a problem ?

    – Roopak Murty
    13 hours ago











  • installed cygwin, and it works now. :-)

    – Roopak Murty
    12 hours ago












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Roopak Murty is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511858%2flooping-through-contents-of-a-file-and-finding-it-in-different-directory%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Using diff may do the trick



diff -crs Dir1 Dir2


It will show you if the files are existing, same or different



with a grep on filename might be what you are looking for






share|improve this answer








New contributor




PhLinuX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • The idea seems to be to verify some sort of manifest over files that are supposed to exist, not to compare two directories.

    – Kusalananda
    14 hours ago











  • i want to check file contents in another directory. example file 1 (located in /user/home) has a,b,c so i need to check if a,b,c is present as files in different folder (/etc)

    – Roopak Murty
    14 hours ago











  • @Kusalananda , yes that is correct, l'm looking for manifest over files that are supposed to exist

    – Roopak Murty
    14 hours ago











  • Ok, sorry, may be read a bit too fast. In that case you could use diff -crs ./file /path_to_file/DIr It also show you where are the differences

    – PhLinuX
    13 hours ago
















0














Using diff may do the trick



diff -crs Dir1 Dir2


It will show you if the files are existing, same or different



with a grep on filename might be what you are looking for






share|improve this answer








New contributor




PhLinuX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • The idea seems to be to verify some sort of manifest over files that are supposed to exist, not to compare two directories.

    – Kusalananda
    14 hours ago











  • i want to check file contents in another directory. example file 1 (located in /user/home) has a,b,c so i need to check if a,b,c is present as files in different folder (/etc)

    – Roopak Murty
    14 hours ago











  • @Kusalananda , yes that is correct, l'm looking for manifest over files that are supposed to exist

    – Roopak Murty
    14 hours ago











  • Ok, sorry, may be read a bit too fast. In that case you could use diff -crs ./file /path_to_file/DIr It also show you where are the differences

    – PhLinuX
    13 hours ago














0












0








0







Using diff may do the trick



diff -crs Dir1 Dir2


It will show you if the files are existing, same or different



with a grep on filename might be what you are looking for






share|improve this answer








New contributor




PhLinuX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










Using diff may do the trick



diff -crs Dir1 Dir2


It will show you if the files are existing, same or different



with a grep on filename might be what you are looking for







share|improve this answer








New contributor




PhLinuX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




PhLinuX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 14 hours ago









PhLinuXPhLinuX

365




365




New contributor




PhLinuX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





PhLinuX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






PhLinuX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • The idea seems to be to verify some sort of manifest over files that are supposed to exist, not to compare two directories.

    – Kusalananda
    14 hours ago











  • i want to check file contents in another directory. example file 1 (located in /user/home) has a,b,c so i need to check if a,b,c is present as files in different folder (/etc)

    – Roopak Murty
    14 hours ago











  • @Kusalananda , yes that is correct, l'm looking for manifest over files that are supposed to exist

    – Roopak Murty
    14 hours ago











  • Ok, sorry, may be read a bit too fast. In that case you could use diff -crs ./file /path_to_file/DIr It also show you where are the differences

    – PhLinuX
    13 hours ago



















  • The idea seems to be to verify some sort of manifest over files that are supposed to exist, not to compare two directories.

    – Kusalananda
    14 hours ago











  • i want to check file contents in another directory. example file 1 (located in /user/home) has a,b,c so i need to check if a,b,c is present as files in different folder (/etc)

    – Roopak Murty
    14 hours ago











  • @Kusalananda , yes that is correct, l'm looking for manifest over files that are supposed to exist

    – Roopak Murty
    14 hours ago











  • Ok, sorry, may be read a bit too fast. In that case you could use diff -crs ./file /path_to_file/DIr It also show you where are the differences

    – PhLinuX
    13 hours ago

















The idea seems to be to verify some sort of manifest over files that are supposed to exist, not to compare two directories.

– Kusalananda
14 hours ago





The idea seems to be to verify some sort of manifest over files that are supposed to exist, not to compare two directories.

– Kusalananda
14 hours ago













i want to check file contents in another directory. example file 1 (located in /user/home) has a,b,c so i need to check if a,b,c is present as files in different folder (/etc)

– Roopak Murty
14 hours ago





i want to check file contents in another directory. example file 1 (located in /user/home) has a,b,c so i need to check if a,b,c is present as files in different folder (/etc)

– Roopak Murty
14 hours ago













@Kusalananda , yes that is correct, l'm looking for manifest over files that are supposed to exist

– Roopak Murty
14 hours ago





@Kusalananda , yes that is correct, l'm looking for manifest over files that are supposed to exist

– Roopak Murty
14 hours ago













Ok, sorry, may be read a bit too fast. In that case you could use diff -crs ./file /path_to_file/DIr It also show you where are the differences

– PhLinuX
13 hours ago





Ok, sorry, may be read a bit too fast. In that case you could use diff -crs ./file /path_to_file/DIr It also show you where are the differences

– PhLinuX
13 hours ago













0














#!/bin/sh

manifest=$1
topdir=$2

while IFS= read -r name; do
pathname="$topdir/$name"

if [ -e "$pathname" ]; then
printf 'Found: %sn' "$pathname" >&2
else
printf 'Not found: %sn' "$pathname" >&2
fi
done <"$manifest"


This script takes a manifest file as its first command line argument, and some directory path as its second argument.



It reads lines from the manifest and tests to see if the pathnames corresponding to those lines exists under the given directory.



Would you only want to test the base name of each name read from the file, then use



#!/bin/sh

manifest=$1
topdir=$2

while IFS= read -r name; do
pathname="$topdir/$( basename "$name" )"

if [ -e "$pathname" ]; then
printf 'Found: %sn' "$pathname" >&2
else
printf 'Not found: %sn' "$pathname" >&2
fi
done <"$manifest"


Related:




  • Understanding "IFS= read -r line"






share|improve this answer
























  • what is pathname="$topdir/$( basename "$name" )" in the above code.. it is showing opposite result Not found:/Users/dir2/a Not found: /Users/dir2/b Not found: /Users/dir2/c , but a ,b, c are present in dir2 as txt files.

    – Roopak Murty
    13 hours ago











  • @RoopakMurty The line creates a new value that is the directory path that is was given followed by the base name of the line read from the file. If the script says that /Users/dir2/a does not exist, well, then that pathname does not exist. The type of file is not taken into consideration. If you could describe a bit more, then maybe I would understand what you mean.

    – Kusalananda
    13 hours ago













  • @RoopakMurty Are you saying that /Users/dir2/a exists? Do you have spaces at the end of the lines in the file that you pass to the script? In that case, delete those spaces.

    – Kusalananda
    13 hours ago













  • yes a is a text file under /Users/dir2 that exists, actually I'm using git bash in windows to run this script, is this a problem ?

    – Roopak Murty
    13 hours ago











  • installed cygwin, and it works now. :-)

    – Roopak Murty
    12 hours ago
















0














#!/bin/sh

manifest=$1
topdir=$2

while IFS= read -r name; do
pathname="$topdir/$name"

if [ -e "$pathname" ]; then
printf 'Found: %sn' "$pathname" >&2
else
printf 'Not found: %sn' "$pathname" >&2
fi
done <"$manifest"


This script takes a manifest file as its first command line argument, and some directory path as its second argument.



It reads lines from the manifest and tests to see if the pathnames corresponding to those lines exists under the given directory.



Would you only want to test the base name of each name read from the file, then use



#!/bin/sh

manifest=$1
topdir=$2

while IFS= read -r name; do
pathname="$topdir/$( basename "$name" )"

if [ -e "$pathname" ]; then
printf 'Found: %sn' "$pathname" >&2
else
printf 'Not found: %sn' "$pathname" >&2
fi
done <"$manifest"


Related:




  • Understanding "IFS= read -r line"






share|improve this answer
























  • what is pathname="$topdir/$( basename "$name" )" in the above code.. it is showing opposite result Not found:/Users/dir2/a Not found: /Users/dir2/b Not found: /Users/dir2/c , but a ,b, c are present in dir2 as txt files.

    – Roopak Murty
    13 hours ago











  • @RoopakMurty The line creates a new value that is the directory path that is was given followed by the base name of the line read from the file. If the script says that /Users/dir2/a does not exist, well, then that pathname does not exist. The type of file is not taken into consideration. If you could describe a bit more, then maybe I would understand what you mean.

    – Kusalananda
    13 hours ago













  • @RoopakMurty Are you saying that /Users/dir2/a exists? Do you have spaces at the end of the lines in the file that you pass to the script? In that case, delete those spaces.

    – Kusalananda
    13 hours ago













  • yes a is a text file under /Users/dir2 that exists, actually I'm using git bash in windows to run this script, is this a problem ?

    – Roopak Murty
    13 hours ago











  • installed cygwin, and it works now. :-)

    – Roopak Murty
    12 hours ago














0












0








0







#!/bin/sh

manifest=$1
topdir=$2

while IFS= read -r name; do
pathname="$topdir/$name"

if [ -e "$pathname" ]; then
printf 'Found: %sn' "$pathname" >&2
else
printf 'Not found: %sn' "$pathname" >&2
fi
done <"$manifest"


This script takes a manifest file as its first command line argument, and some directory path as its second argument.



It reads lines from the manifest and tests to see if the pathnames corresponding to those lines exists under the given directory.



Would you only want to test the base name of each name read from the file, then use



#!/bin/sh

manifest=$1
topdir=$2

while IFS= read -r name; do
pathname="$topdir/$( basename "$name" )"

if [ -e "$pathname" ]; then
printf 'Found: %sn' "$pathname" >&2
else
printf 'Not found: %sn' "$pathname" >&2
fi
done <"$manifest"


Related:




  • Understanding "IFS= read -r line"






share|improve this answer













#!/bin/sh

manifest=$1
topdir=$2

while IFS= read -r name; do
pathname="$topdir/$name"

if [ -e "$pathname" ]; then
printf 'Found: %sn' "$pathname" >&2
else
printf 'Not found: %sn' "$pathname" >&2
fi
done <"$manifest"


This script takes a manifest file as its first command line argument, and some directory path as its second argument.



It reads lines from the manifest and tests to see if the pathnames corresponding to those lines exists under the given directory.



Would you only want to test the base name of each name read from the file, then use



#!/bin/sh

manifest=$1
topdir=$2

while IFS= read -r name; do
pathname="$topdir/$( basename "$name" )"

if [ -e "$pathname" ]; then
printf 'Found: %sn' "$pathname" >&2
else
printf 'Not found: %sn' "$pathname" >&2
fi
done <"$manifest"


Related:




  • Understanding "IFS= read -r line"







share|improve this answer












share|improve this answer



share|improve this answer










answered 14 hours ago









KusalanandaKusalananda

141k17263439




141k17263439













  • what is pathname="$topdir/$( basename "$name" )" in the above code.. it is showing opposite result Not found:/Users/dir2/a Not found: /Users/dir2/b Not found: /Users/dir2/c , but a ,b, c are present in dir2 as txt files.

    – Roopak Murty
    13 hours ago











  • @RoopakMurty The line creates a new value that is the directory path that is was given followed by the base name of the line read from the file. If the script says that /Users/dir2/a does not exist, well, then that pathname does not exist. The type of file is not taken into consideration. If you could describe a bit more, then maybe I would understand what you mean.

    – Kusalananda
    13 hours ago













  • @RoopakMurty Are you saying that /Users/dir2/a exists? Do you have spaces at the end of the lines in the file that you pass to the script? In that case, delete those spaces.

    – Kusalananda
    13 hours ago













  • yes a is a text file under /Users/dir2 that exists, actually I'm using git bash in windows to run this script, is this a problem ?

    – Roopak Murty
    13 hours ago











  • installed cygwin, and it works now. :-)

    – Roopak Murty
    12 hours ago



















  • what is pathname="$topdir/$( basename "$name" )" in the above code.. it is showing opposite result Not found:/Users/dir2/a Not found: /Users/dir2/b Not found: /Users/dir2/c , but a ,b, c are present in dir2 as txt files.

    – Roopak Murty
    13 hours ago











  • @RoopakMurty The line creates a new value that is the directory path that is was given followed by the base name of the line read from the file. If the script says that /Users/dir2/a does not exist, well, then that pathname does not exist. The type of file is not taken into consideration. If you could describe a bit more, then maybe I would understand what you mean.

    – Kusalananda
    13 hours ago













  • @RoopakMurty Are you saying that /Users/dir2/a exists? Do you have spaces at the end of the lines in the file that you pass to the script? In that case, delete those spaces.

    – Kusalananda
    13 hours ago













  • yes a is a text file under /Users/dir2 that exists, actually I'm using git bash in windows to run this script, is this a problem ?

    – Roopak Murty
    13 hours ago











  • installed cygwin, and it works now. :-)

    – Roopak Murty
    12 hours ago

















what is pathname="$topdir/$( basename "$name" )" in the above code.. it is showing opposite result Not found:/Users/dir2/a Not found: /Users/dir2/b Not found: /Users/dir2/c , but a ,b, c are present in dir2 as txt files.

– Roopak Murty
13 hours ago





what is pathname="$topdir/$( basename "$name" )" in the above code.. it is showing opposite result Not found:/Users/dir2/a Not found: /Users/dir2/b Not found: /Users/dir2/c , but a ,b, c are present in dir2 as txt files.

– Roopak Murty
13 hours ago













@RoopakMurty The line creates a new value that is the directory path that is was given followed by the base name of the line read from the file. If the script says that /Users/dir2/a does not exist, well, then that pathname does not exist. The type of file is not taken into consideration. If you could describe a bit more, then maybe I would understand what you mean.

– Kusalananda
13 hours ago







@RoopakMurty The line creates a new value that is the directory path that is was given followed by the base name of the line read from the file. If the script says that /Users/dir2/a does not exist, well, then that pathname does not exist. The type of file is not taken into consideration. If you could describe a bit more, then maybe I would understand what you mean.

– Kusalananda
13 hours ago















@RoopakMurty Are you saying that /Users/dir2/a exists? Do you have spaces at the end of the lines in the file that you pass to the script? In that case, delete those spaces.

– Kusalananda
13 hours ago







@RoopakMurty Are you saying that /Users/dir2/a exists? Do you have spaces at the end of the lines in the file that you pass to the script? In that case, delete those spaces.

– Kusalananda
13 hours ago















yes a is a text file under /Users/dir2 that exists, actually I'm using git bash in windows to run this script, is this a problem ?

– Roopak Murty
13 hours ago





yes a is a text file under /Users/dir2 that exists, actually I'm using git bash in windows to run this script, is this a problem ?

– Roopak Murty
13 hours ago













installed cygwin, and it works now. :-)

– Roopak Murty
12 hours ago





installed cygwin, and it works now. :-)

– Roopak Murty
12 hours ago










Roopak Murty is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Roopak Murty is a new contributor. Be nice, and check out our Code of Conduct.













Roopak Murty is a new contributor. Be nice, and check out our Code of Conduct.












Roopak Murty is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511858%2flooping-through-contents-of-a-file-and-finding-it-in-different-directory%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...