- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
I need to delete the footer from the file like below and copy to another file.
SGW|SGW_CDR_|2017-12-09 174338|2017-12-10 003143|2017-12-09 213311|2017-12-10 013310|39246|0200005649
SGW|SGW_CDR_|2017-12-09 174338|2017-12-10 003143|2017-12-09 213311|2017-12-10 013310|39246|0200005649
SGW|SGW_CDR_|2017-12-09 174338|2017-12-10 003143|2017-12-09 213311|2017-12-10 013310|39246|0200005649
SGW|SGW_CDR_|2017-12-09 174338|2017-12-10 003143|2017-12-09 213311|2017-12-10 013310|39246|0200005649
SGW|SGW_CDR_|2017-12-09 174338|2017-12-10 003143|2017-12-09 213311|2017-12-10 013310|39246|0200005649
SGW|SGW_CDR_|2017-12-09 174338|2017-12-10 003143|2017-12-09 213311|2017-12-10 013310|39246|0200005649
Total Recs:6
The below linux command is working fine in putty.
awk 'NR>1 && /./ { print buf; buf=rs=""} { buf=(buf rs $0); rs=RS } END { if (i=index(buf,RS)) print substr(buf,i+1) }' file1 > file2
but the below x command is giving error :
x " awk 'NR>1 && /./ { print buf; buf=rs=""} { buf=(buf rs $0); rs=RS } END { if (i=index(buf,RS)) print substr(buf,i+1) }' file1 > file2 2>&1" ;
The error is:
awk: NR>1 & /./ { print buf; buf=rs="} { buf=(buf rs $0); rs=RS } END { if (i=index(buf,RS)) print substr(buf,i+1) }
awk: ^ syntax error
awk: NR>1 & /./ { print buf; buf=rs="} { buf=(buf rs $0); rs=RS } END { if (i=index(buf,RS)) print substr(buf,i+1) }
awk: ^ unterminated string
Any Ideas on how to resolve this issue?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You're encountering an issue because the command you want to run contains both single and double quotes. Yet the X command requires its command to be in quotes. That would require changing the command, unless ...
Switch from X to %sysexec. For all practical purposes, it performs the identical function but doesn't require quotes:
%sysexec awk 'NR>1 && /./ { print buf; buf=rs=""} { buf=(buf rs $0); rs=RS } END { if (i=index(buf,RS)) print substr(buf,i+1) }' file1 > file2;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You're encountering an issue because the command you want to run contains both single and double quotes. Yet the X command requires its command to be in quotes. That would require changing the command, unless ...
Switch from X to %sysexec. For all practical purposes, it performs the identical function but doesn't require quotes:
%sysexec awk 'NR>1 && /./ { print buf; buf=rs=""} { buf=(buf rs $0); rs=RS } END { if (i=index(buf,RS)) print substr(buf,i+1) }' file1 > file2;