문제

I am trying to create an alias for the following command

lsof -i :$1 | awk 'NR!=1 {print $2}' | xargs kill

However I keep getting an error:

lsof: unacceptable port specification in: -i :

I tried different things but I keep failing to pass the port number successfully. How can I pass the port number into this alias?

도움이 되었습니까?

해결책

If you need to pass a parameter into a specific position, an alias cannot be done. Instead, create a function:

myfunc() {
   lsof -i :$1 | awk 'NR!=1 {print $2}' | xargs kill
}

If you save it in your ~/.bashrc file you will be able to call it with myfunc parameter.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top