removing "\r" while using command cp , grep & awk
Hello,
I am using the below command to grep a file & get the 3rd field(which is a file name) of it then copy that to an directory bin. Command: cp $(grep "EXETARGET" Makefile | awk '{print 3}') $EB2/build/debug/bin But getting an error saying " cp: cannot stat 'aljobtemplatemgr\r': no such file or directory" The name is getting appended by \r. How do i remove the "\r" from the 'aljobtemplatemgr\r' Any suggestions is appreciated. Thanks in advance. Regards -Rakesh |
Hi,
The Makefile you are using as input is probably a dos file, not a unix/linux file, that is why the \r is added. If creating/changing the Makefile(s) to unix/linux file(s) is not an option: cp $(awk '/EXETARGET/ {sub(/\r/,"",$3) ; print $3 }' Makefile) $EB2/build/debug/bin This removes the grep part (not needed, awk can do this also). Awk's sub(x,y,z) function removes the \r from field 3 before printing it. Hope this helps. |
Hello,
Its hanging .. never coming out. |
Hi,
Having a lot of info to work with is always nice...... I assume that the Makefile is a dos file (is it?). A sample run: Code:
$ cat Makefile Are you using gawk (awk --version)? If not, which awk is used? Is the oneliner an actual oneliner or is it part of a larger (shell) script? |
Thanks.. It worked.. Missing an space.
|
All times are GMT -5. The time now is 08:03 AM. |