![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script to capture new lines in a file and copy it to new file | fara_aris | Shell Programming and Scripting | 0 | 05-27-2008 07:11 PM |
| capture ping to a file | MizzGail | SUN Solaris | 3 | 09-20-2007 06:31 AM |
| Capture Value from file | kris01752 | UNIX for Advanced & Expert Users | 1 | 08-28-2006 07:50 PM |
| Capture the command run in the log file | ahmedwaseem2000 | Shell Programming and Scripting | 4 | 08-09-2006 10:06 AM |
| capture nohup log file | mgirinath | Shell Programming and Scripting | 2 | 04-24-2006 01:51 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
capture the file name
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
header_fname=`awk 'NR==2 { print substr($0,1,length-18) }' $1`
echo $header_fname
Code:
#!/bin/ksh
{
read line
read line
} < $1
header_fname=${line%??????????????????}
echo $header_fname
|
|
#3
|
||||
|
||||
|
Quote:
|
|
#4
|
||||
|
||||
|
Quote:
Jean-Pierre. |
|
#5
|
|||
|
|||
|
Thank you Aigles, it is working perfectly.
|
|||
| Google The UNIX and Linux Forums |