I doing the follwing script , but found problem to store it to a shell variable.
It shows me all the file ending with .file under ./dat/vector directory.
But I want to store the value of ( in this case ) a[4] to a shell variable fname and also the base name of the file ie, drf in this case to a separate shell variable called basename..
If any other idea with sed or with any other command most welcome..
Objective is to find all the file with extension .file and then store only the file name to a shell variable
and the base name of the file to another shell variable.
I tried with the above code but getting error..
Thanks & Regards,
User_prady
Last edited by user_prady; 11-28-2007 at 09:21 PM..
Maybe I am missing something here but why not just use the basename utility to achieve what you want instead of awk?
Dear Murphy,,
Thanks for your reply ..
I ve no idea about the base utility you are telling about . Would you please explain me with code how to achieve my goal here..
fpmurphy is refering to a useful commandline tool called 'basename'
It returns everything after the last / character.
So if you call:
basename /thing/blah/stuff/filename
you get:
filename
You can use this to get just the filename out of your data
fpmurphy is refering to a useful commandline tool called 'basename'
It returns everything after the last / character.
So if you call:
basename /thing/blah/stuff/filename
you get:
filename
You can use this to get just the filename out of your data
Although I heard it first time, It seems to be reli interesting ..Will try this soon.......Thanks
Cool ........Its reli Handy..
Last edited by user_prady; 11-28-2007 at 11:29 PM..
fpmurphy is refering to a useful commandline tool called 'basename'
It returns everything after the last / character.
So if you call:
basename /thing/blah/stuff/filename
you get:
filename
You can use this to get just the filename out of your data
I'm converting decimal to integer with bc, and I'd like to assign the integer output from bc to a variable 'val'.
E.g. In the code below: If b is 5000.000, lines 6 and 8 will output:
5000
(5000.000+0.5)/1 | bc
I'd like val to take the value 5000 though, rather than 5000.000
Does someone... (3 Replies)
I have a script whose contents are as below
result= awk 's=100 END {print s }'
echo "The result is" $result
The desired output is
The result is 100
My script is running without exiting and i am also not getting the desired output.
Please help (5 Replies)
I am trying to assgn the output of the select statement to a variable, like this
"VARIABLE_NAME=$ db2 "select COLUMN_NAME_1 from TABLE_NAME where COLUMN_NAME_2='VALUE_TO_CHECK'"; "
but the value that is getting into VARIABLE_NAME is
"COLUMN_NAME_1
-----------------
VALUE
1... (3 Replies)
i'm on a Mac running BSD unix.
i have a script in which i ask the user to input the name of a mounted volume. i then call SED to substitute backslashes and spaces in place of the spaces. that looks like this:
echo "Enter the name of the volume"
read Volume
echo "You've chosen \"$Volume\""... (7 Replies)
When I run time -p <command>, it outputs:
real X.XX
user X.XX
sys X.XXwhere X.XX is seconds. How I can take just that first number output, the seconds of real time, and assign that to a variable? (9 Replies)
I am new to unix shell scripting.
I was trying to convert each lines in a file to upper case.
I know how to convert the whole file.
But here i have to do line by line.
I am getting it in the below mentioned script
#!/bin/bash
#converting lower to upper in a file
#tr "" "" <file1... (3 Replies)
hi,
I want to assign find command result into some temporary variable:
jarPath= find /opt/lotus/notes/ -name $jarFile
cho "the jar path $jarPath"
where jarPath is temporary variable.
Can anybody help on this.
Thanks in advance
----Sankar (6 Replies)
I have the sql file cde.sql with the below contents:
abcdefghij
abcwhendefothers
sdfghj
when no one else
when others
wwhen%others
exception when others
Now I want to search for the strings containing when others together and ceck whether that does not occur more than once in the... (2 Replies)
Hi,
I'm trying to assign the output of a command to a variable and then concat it with another string, however, it keeps overwriting the original string instead of adding on to the end of the string.
Contents of test.txt --> This is a test
var1="`head -n 1 test.txt`"
echo $var1 (This is a... (5 Replies)
I do a lot of command line scripting to capture data from files or other command output. I've checked in a number of Unix and scripting books but for the life of me I can't find out how to asign field data from nawk output into variables that I can manipulate later. For example, reading a two... (6 Replies)