« first day (2389 days earlier)      last day (680 days later) » 

12:30 AM
@edjm : I'm not sure I understand your problem complelely, but going up a directory implies that there is a a /path/to/angular/files.txt already established. If this is in a variable, you can remove the last subdir (one at a time with) var="/dir1/dir2/dir3/dir4/file.txt" ; newVar=${var%/*} ; echo $newVar . you'll have to put that in a loop that exits once you find the correct file. Good luck.
Note the low number of users here on the chat (sadly (-;) ). .... Learn to write a good question with minimal data and side-topics and you will usually get a good answer from the bash squad within hours.
See stackoverflow.com/tags/bash/info particularly the section "How to turn a bad script into a good question". Good luck!
 
 
13 hours later…
2:14 PM
Hi Shelter. I'll try and explain this better with a folder layout.
>workspace
> > project a
> > > some component folder with test files
> > > node_modules/@angular
> > project b
> > > some component folder with test files
> > > node_modules/@angular

Each of the projects have a different version of Angular within the node_modules.
From within each of the 'component test files folder' locations I need to be able to run my function that will be able to traverse up n number of folders until it finds the node_modules directory with the @angular inside it. But also I don't want it to go above t
 
2:58 PM
how am i dealing with white spaces in the path ?
/Users/adrian/Dropbox\ (Sports\ Details)/Imaging/Local_Folders/EU_imaging/Global_Python/Imaging_Desktop_App/app.py
 
 
5 hours later…
 
1 hour later…
8:43 PM
@Andie31 : are you helping/working with edjm from above? In any case, rather than trying to manage escaping individual space chars, always surround path/file elements with dbl-quote chars. so any reference should be like "/path with/spaces/file name.txt". You need to do this when you assign a path/file value to a variable var="/path with/spaces/file name.txt" AND when you use the variable, i.e. cd "$var".
 
8:54 PM
@edjm : something like set -vx; myRequiredfile="py_lib_special_7.3.py" ; longest_path="/dir1/dir2/dir3/dir4/file.txt"; shorter_path="${longest_path%/*}"; while [[ "$shorter_path" != "" && ! -f "$shorter_path/$myRequiredfile" ]] ; do shorter_path="${shorter_path%/*}" ; done ; set +vx might help you. Again, I urge to get some sort of code working and post a question with a [bash] tag. I won't be able to spend more time of this. ....
The set -vx ; set +vx bookends turn on the shell debugging (and turn it off). THis makes it easier to see the processing that is happening inside the loop. The ${var%/*} is called a paramter substitution and it removes the matching pattern from the end of the variable (but doesn't change the variable's value). There is also a ${var#*/} that removes from the front of the string, and there are %% and ## variants that match (and remove) the longest possible match in the string. Good luck.
Given you use case as described, I don't think you'll need the ## or %% versions for this puzzle. Got to go. Good luck!
 

« first day (2389 days earlier)      last day (680 days later) »