The way you've got it will actually work. However I'd change it just a little bit:
The double quotes let it properly handle directory names containing spaces, which might otherwise be split into multiple arguments unexpectedly. The brackets around the variables let it identify variables in otherwise-ambiguous situations like $R_not_a_variable.
Hi,
I'm using ksh and I'm trying to shorten a column of figures. For example, I'd like to turn:
3456789.9876 to 89.98
567.4956 to 67.49
4669493932.34564 to 32.34
... so the input figure will vary in length, I'm not worried about rounding, I just want the two... (6 Replies)
If I the path to a directory, what command can I use to return the actual name of that directory.
test=`pwd`/folder1
> $test
folder1
I'd rather avoid anything with regular expressions. Any ideas? (1 Reply)
Hi,
I have a file abcd.txt which has contents in the form of full path file names i.e.
$home> vi abcd.txt
/a/b/c/r1.txt
/q/w/e/r2.txt
/z/x/c/r3.txt
Now I want to retrieve only the directory path name for each row
i.e
/a/b/c/
/q/w/e/
How to get the same through shell script?... (7 Replies)
If I enter (simplified):
find . -printf "%p\n"
then all files in the output are prepended by a "." like
./local/share/test23.log
How can achieve that
a.) the leading "./" is omitted
and/or
b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
there was a post previously about this from around 2010
but i was unable to get the suggested scripts there to work.
the following code works for me when it's saved inside the
directory of files whose names i want to shorten, but i would
like to be able to store it in a file with a list of ... (4 Replies)
The purpose of the below is to grab the 9th field of the data in "$epochtimeframe". and then translate that data (which is an epoch time), into a human readable form.
echo $epochtimeframe | awk -F"--" '{print $9}' | awk -F"," '{print $2}' | perl -pe 's/(\d+)/localtime($1)/e'
i'm sure many... (10 Replies)
Hello,
I am looking for a command that will give me the last directory name from a path
ex 1 :
/dir1/dir/2/dir3/
output needed
dir3
ex 2 :
/dir1/dir/2/dir3/dir4/
output needed
dir4 (1 Reply)
My input is as below :
/splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt
/splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt
/splunk/scrubbed/loyal/IFIND.HELLO.WROC.txt
/splunk/scrubbed/triumph/ifind.triumph.txt
From the above input I want to extract the file names only .
Basically I want to... (5 Replies)
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)