
05-25-2007
|
 |
Shell programmer, author
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 977
|
|
Quote:
|
Originally Posted by Mandab
I am trying to capture the file name(which is not of fixed length) and put it in a variable. It is working in unix whereas when I am running the same script in Informatica it is not giving me the desired output. But when I comment the option(find the file name) then it is working fine. It can also because I am using awk. Is there any other way(other than using awk) to find the file name? File name will be in second line of the file with 2 other items filesize numeric(10) and record count numeric(8).
Here is my code:
#!/bin/ksh
eval $(awk 'NR==2 {
printf "header_fname=\"%s\"\n", substr($0,1,length-18) ## filename
}' $1)
echo "$header_fname"
Sample file:
id_xyz20070523085554004
abcdefgh.csv000000324100000036
|
In any BOURNE-type shell (bash, ksh, sh, etc.):
Code:
{
read line
IFS=0123456789 read header_fname junk
} < "$FILE"
echo "$header_fname"
|