Shifting of lines in a file

Hi all,

I am using the below command to shift the lines in a file which was advised by Anchal in this forum:

awk -v total_records=$(cat redirects.virgin-atlantic.com.conf | wc -l) '{ if(NR>(total_records - 2)) printf "\t%s\n", $0; else print $0 }' align

but I am getting the below error:
awk: syntax error near line 1
awk: bailing out near line 1

but for anchal it is working fine.

The OS I am using for Unix is:
SunOS 5.8 Generic_108528-23 sun4u sparc SUNW,Sun-Fire-280R

Please can somebody advise.

Best Regards,
Shazin

As radoulov always says:

I would guess that the wc -l is returning leading spaces

Try

total_records=$(echo $(cat redirects.virgin-atlantic.com.conf | wc -l))

Useless Use of Cat!

total_records=$(wc -l < redirects.virgin-atlantic.com.conf)

Regards

Hi All,

Giving the same error.

Best Regards,
Shazin

Did you try it with /usr/xpg4/bin/awk?

It works fine with that.

Hi all,

Please follow the original thread.

Shazin: Posting again will only start assumptions from the beginning.

Thread closed, warning given to stay in old thread with same problem - Please continue where anchal_khare refers to, ty.