Hi,
I am new to UNIX Scripting. I have been trying to use the CUT command to retrieve part of the header from a file and assign it to a variable. I have tried searching a lot, but I am still unsuccessful.
Sample Header: HJAN BALANCE 20090616
I need to retrieve the date here, which always ranges from the 18-25 position.
Thank you Rakesh.
I tried this. Below is the response:
Header Line: HJAN BALANCE 20090616
cut: cannot open HJAN
cut: cannot open BALANCE
cut: cannot open 20090616
Launch_LKW-Gen.ksh[136]: headerDate: not found
Header Date:
I got the reason after I posted the previous one. The separators between the three values is a TAB and not multiple spaces. I realized when I pasted the output here. There is only one space now, which is actually a TAB.
May be I should use the -d option and retrieve the 3rd value?
Following is the content of the first line of the file:
HJAN BALANCE 20090616
The possible inputs are following:
HJAN BALANCE 20090616
HJAN HOLDING 20090616
HJAN CASHLEDGER20090616
Hence it worked for the first two. Hence I feel in my case the best approach would be to retrieve the last 8 characters. But since there are trailing spaces, I need to first trim the line then retrieve the last 8.