Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.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
Shell 我正在尝试从类似“windows”的文件中删除windows文件路径\abc\";但我不确定在unix中需要使用哪个命令_Shell_Unix - Fatal编程技术网

Shell 我正在尝试从类似“windows”的文件中删除windows文件路径\abc\";但我不确定在unix中需要使用哪个命令

Shell 我正在尝试从类似“windows”的文件中删除windows文件路径\abc\";但我不确定在unix中需要使用哪个命令,shell,unix,Shell,Unix,我正在尝试从类似“\abc\”的文件中删除windows文件路径,但我不确定在Unix中需要使用哪个命令 我尝试了tr-d'\abc\',但它不起作用。我还可以使用其他命令吗?使用sed: echo 'c:\path1\abc\dir 2\file.txt' | sed 's/\\abc//' 以下方法通常有效。bash中有一个名为basename的函数,它会自动删除除文件名以外的所有内容 filename=$(basename "$fullfile") 范例 basename('C:/te

我正在尝试从类似
“\abc\”
的文件中删除windows文件路径,但我不确定在Unix中需要使用哪个命令

我尝试了
tr-d'\abc\'
,但它不起作用。我还可以使用其他命令吗?

使用sed:

echo 'c:\path1\abc\dir 2\file.txt' | sed 's/\\abc//'

以下方法通常有效。bash中有一个名为basename的函数,它会自动删除除文件名以外的所有内容

filename=$(basename "$fullfile")
范例

basename('C:/test/test.txt')

屈服

test.txt

哼,如果
echo'c:\path1\abcd\file.txt'|sed's/\\abc/'
,这会中断。但是可以很容易地修复:
echo'c:\path1\abcd\file.txt'| sed's/\\abc\\/\\/'