![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Assigning output to a variable | jpmena | Shell Programming and Scripting | 3 | 03-27-2008 04:39 AM |
| Assigning output of command to a variable in shell | sankar reddy | Shell Programming and Scripting | 6 | 02-28-2008 03:01 AM |
| assigning command output to a shell variable | kprattip | Shell Programming and Scripting | 2 | 07-09-2007 05:01 AM |
| Assigning output of command to a variable | oma04 | Shell Programming and Scripting | 5 | 06-27-2006 01:11 PM |
| Assigning nawk output to variables | steveje0711 | Shell Programming and Scripting | 6 | 08-19-2005 06:03 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hello friends, I doing the follwing script , but found problem to store it to a shell variable. Code:
#! /bin/sh
for temp in `find ./dat/vector/ -name '*.file'`
do
echo $temp
nawk -v temp=$temp 'BEGIN{ split(temp, a,"\/"); print a[4]}'
done
output:
./dat/vector/drf_all_002.file
drf_all_002.file
......
......
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. Code:
#! /bin/sh
for temp in `find ./dat/vector/ -name '*.file'`
do
echo $temp
fname = `nawk -v temp=$temp 'BEGIN{ split(temp, a,"\/"); print a[4]}' `
done
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.. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|