Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在linux中仅从文本文件中删除垃圾字符_Linux_Shell - Fatal编程技术网

在linux中仅从文本文件中删除垃圾字符

在linux中仅从文本文件中删除垃圾字符,linux,shell,Linux,Shell,我有一个文本文件,其中包含文件夹和文件名,中间插入了垃圾字符。我只想筛选文件夹名称,下面是一个示例: /TEST/C/Users/Account/Documents/T/Java/Reach/con/trail-and-error/modify/web/jk/args-pasre/library/°/°/°/°/°/°/°/°/°/°/°/key-check-folat.js 我希望我的输出是: /TEST/C/Users/Account/Documents/T/Java/Reach/con/

我有一个文本文件,其中包含文件夹和文件名,中间插入了垃圾字符。我只想筛选文件夹名称,下面是一个示例:

/TEST/C/Users/Account/Documents/T/Java/Reach/con/trail-and-error/modify/web/jk/args-pasre/library/°/°/°/°/°/°/°/°/°/°/°/key-check-folat.js
我希望我的输出是:

/TEST/C/Users/Account/Documents/T/Java/Reach/con/trail-and-error/modify/web/jk/args-pasre/library/key-check-folat.js
尝试执行以下操作,但它会从列表中删除“/”和“-”字符

echo "/TEST/C/Users/Account/Documents/T/Java/Reach/con/trail-and-error/modify/web/jk/args-pasre/library/°/°/°/°/°/°/°/°/°/°/°/key-check-folat.js" | tr -cd '[:alnum:]'
对于sed:

$ echo "/TEST/C/Users/Account/Documents/T/Java/Reach/con/trail-and-error/modify/web/jk/args-pasre/library/°/°/°/°/°/°/°/°/°/°/°/key-check-folat.js" | sed 's/\/°//g'
/TEST/C/Users/Account/Documents/T/Java/Reach/con/trail-and-error/modify/web/jk/args-pasre/library/key-check-folat.js

“垃圾”是什么意思?“/”/“/”/“/”/”/“/”/”/“/”/”/“/”/”/这些字符与
sed-E的/\/[^A-Za-z0-9.\u-]+/'
类似可能更好,如果他指定要删除所有非字母数字字符的话。同意,“垃圾”字符引用不明确,您可以很好地处理他给出的示例。