What do you think would be the simplest test?
Never thought about using ls?
If it displays: "No such file or directory " then you dont cd...
I'm not looking for a way to find a directory, I'm looking for a way to get the full path based on a shell script's working directory and a directory argument sent to the script, into a variable.
The only option I see is testing the user input to the shell to see what you want to do from there. A case/esac structure might work well in this instance. Perhaps coupled with "dirname"
Something like
You need to replace the ellipses with one test for each level it can go beyond the script's parent/parent directory back to root.
Obviously you replace the echo statements with code that actually works for you.
dirname seems to know that if you give the name "somewhere" or the name "./somewhere" it will translate that to a single dot "." so that reduces the amount of
tests by one.
And of course after I post that, I realize there's still a host of things that wont work correctly, depending upon input like (../somewhere/else) but maybe this will get you started somewhat? :-)
Looking more and more like homework, and no collaboration ( you havent shown so far anything of your work without paying attention to what is said there...)
So until you can prove it is not, this thread is considered as homework by someone unwilling to learn and closed
---------- Post updated at 18:06 ---------- Previous update was at 18:05 ----------
Hello,
I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Hi All,
i had to split one files into 10 equally. For that i have coded below awk.
OUTPUT_FILE=/home/sit/path/Files/file_EXPORT.lst
DIR_NM=`dirname ${OUTPUT_FILE}`
awk -v CURR_DATE="$(date +'%d-%m-%Y-%H-%M')" -v pth=$DIR_NM '{print >> pth/"tgt_file_name"CURR_DATE"_"NR%10 }' ${OUTPUT_FILE}
... (7 Replies)
I would like to install a binary from source on a custom path, say /usr/local/myapps. There is no --prefix option in ./configure How can I "make install" at custom path. I tried this.
No --prefix
root@server # ./configure --help | grep prefix
root@server #
Make install
... (3 Replies)
I have a script like this running under OS X 10.8. The problem arises when the find command encounters a space in the path name. I need the "dir" variable as I'll be extending the script to more general use.
#!/bin/bash
CFS=$IFS
IFS=$(echo)
set dir = "/Users/apta/Library/Mail\... (3 Replies)
I am trying to configure gpac. I get the error as follows.
# ./configure
error: zlib not found on system or in local libs
I have installed zlib on custom path /usr/local/myapps. I know the above error occurs when devel package or .h file is not present. Its present on the server.
# ll... (7 Replies)
I need to write a login script for multiple computers, however, one of the directories in question will have a different name from computer to computer.
~/Library/Application\ Support/Firefox/Profiles/<unique filename>.default/myfile
For the directory named <unique filename>.default , I... (2 Replies)
Hello,
i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem.
my var1 is a string constructed like this:
filename1 filerev1 filepath1
my var2 is another string constructed like this:
filename2 filerev2 filepath2
when i do... (2 Replies)