Extracting directory name from an absolute path using sed or awk

后端 未结 6 1059
忘掉有多难
忘掉有多难 2021-01-05 13:29

I want to split this line

/home/edwprod/abortive_visit/bin/abortive_proc_call.ksh

to

/home/edwprod/abortive_visit/bin
         


        
6条回答
  •  再見小時候
    2021-01-05 14:34

    May be command dirname is what you searching for?

    dirname /home/edwprod/abortive_visit/bin/abortive_proc_call.ksh
    

    Or if you want sed, so see my solution:

    echo /home/edwprod/abortive_visit/bin/abortive_proc_call.ksh | sed 's/\(.*\)\/.*/\1/'
    

提交回复
热议问题