I have a simple script in three parts:
- Search for files, get the results from the find command, pipe those results to sed to strip out the filename, and finally pipe those results to a file: pathlist.txt
- Read the contents, line by line, of pathlist.txt to an array in a bash script
- Use the array to create soft links to the entries in pathlist.txt.
I’ve got everything working as long as I don’t use step #2. If I define an array with hard values then the script runs, but if I use a while loop to read the file it just hangs. I’m assuming I have the syntax wrong for reading a file with a while loop. Here’s what I have:
find -H /mnt/restore/ -iname wphost.db | sed -e ‘s/wphost.db//’ > pathlist.txt
That works. I get exactly what I want in that file.
# Use while loop to read each line, which is a path, into the array
while read line<pathlist.txt; do
I know this must be a basic question, but I’ve moved from Novell to Windows, back to Novell, and now Linux. Any help is appreciated. Please dumb it down, the internet is full of forums about linux with admins who give answers without any explanation at all.