0

While trying to trim carriage return \n from a command, also removed the \n from the end as well, hence I am not able to execute the command. The Below Command:

ps -ef| grep "xyz.jar" | cut -d ' ' -f2

Gives:

{newline}
12334{newline}

I wanted to append a kill -9 command with this, hence I needed the last {newline}, not the first one.

How can I delete just the first {newline} in this?

Joaquin
  • 1,307
  • 2
  • 11
  • 23
Nitish
  • 11
  • 1
  • 2
    Please avoid *"Give me the codez"* questions that have been asked and answered so many times you have to make an effort to avoid finding an answer. Instead show the script you are working on and state where the problem is. Also see [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/q/261592/608639) – jww Aug 07 '18 at 05:35
  • are you trying to kill a specific command here – Inder Aug 07 '18 at 06:50
  • 1
    @jww I see OP has shown the code they have tried as well as stating where the problem is(as per their understanding)... so your comment doesn't make sense to me.. – Sundeep Aug 07 '18 at 06:55
  • @Nitish, use `pgrep` and `pkill` instead of `ps`.. for ex: see https://stackoverflow.com/questions/8120304/getting-pids-from-ps-ef-grep-keyword, https://stackoverflow.com/questions/160924/how-can-i-kill-a-process-by-name-instead-of-pid and https://stackoverflow.com/questions/8987037/how-to-kill-all-processes-with-a-given-partial-name – Sundeep Aug 07 '18 at 06:58
  • @Nitish any feedback after the answer below? – Lino Aug 07 '18 at 16:34

0 Answers0