Ubuntu bash script: how to split path by last slash?

前端 未结 4 1524
忘掉有多难
忘掉有多难 2020-12-12 22:17

I have a file (say called list.txt) that contains relative paths to files, one path per line, i.e. something like this:

foo/bar/file1
foo/bar/ba         


        
4条回答
  •  没有蜡笔的小新
    2020-12-12 22:59

    Here is one example to find and replace file extensions to xml.

    for files in $(ls); do
    
        filelist=$(echo $files |cut -f 1 -d ".");
        mv $files $filelist.xml;
    done
    

提交回复
热议问题