Originally Posted by mxa055
I have a case where I need to return some data written by hand inside a textfile back from a bash script. And because an example will best explain what I want to say here goes.
I have a folder that has some files and some subfolders.
I write inside this folder a file that contains a list of what I want to be returned in sequence i.e.
I need some code that will output:
-file1 (this should only be outputed once no matter how many times the script processes the list file)
-folder1/file7 (all the files that are contained inside folder1
-folder2/file9 (same as folder1)
Note: folders contain a processme.lst file as well
The way I have implemented it so far finds the processme.lst file in the folder and reads the #insequence special entry so starts running the insequence script with arguments all the files listed below it.
so "sh insequence.sh file1 folder1 file2 file3 folder2"
if i put just files the script runs fine returning the files one by one in sequence by shifting the arguments. When a folder is found only one file from the folder is returned (this should return all the files). Also I haven't found a way of saying that do not return the first entry ever again.
I tried stopping to shift arguments when a folder is encountered but that got me stack inside the folder and never returned.
Any tips putting me in the right direction would be greatly appreciated
Once you are able to clearly describe what you want, post again. No one is going to be able to turn your prose into code, and your computer certainly won't be able to either.
To solve this problem, think like a computer -- dumb and literal. List the actions, the steps to get to a solution. Leave nothing to the imagination. If you are specific and literal enough, you should be able to turn your list into a program.
... by shifting the arguments
Don't do it that way -- use an array and/or a loop to scan the arguments. I say this because if you pass the arguments through the command line and try to shift them, after seeming to function correctly your program will suddenly complain that the list is too long. Avoid this problem at the outset by avoiding the method at the design stage.