Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
RPO.RE4_SND_MSG_RECO_Q_n_message
i have an line like this. I would like to cut till RPO.RE4_SND_MSG_RECO_Q . when i used
cut -d '_' _f4
it gave oly RECO as output .please help me Newbie to unix
You can use:
s='RPO.RE4_SND_MSG_RECO_Q_n_message'
cut -d_ -f1-5 <<< "$s"
RPO.RE4_SND_MSG_RECO_Q
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
Using the uprobe example for hooking bash's readline gives one line at a time. What/How should I hook to get multi-line commands?
I tried hooking add_history but that gives me only one line.
Example input:
cat EOF
x
<< EOF
ls \
| grep
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have a text file (foo.txt) containing a number of URLs. Each URL contains a file ID:
www.url.com/etc/one/two/72f66_59875c1ffb57b5992-b18/something/maybe/
www.url.com/etc/8823cd1-ab9532a5dc74cc904cc6bd3e2/perhaps/
www.url.com/etc/something/8407fb_80bbb9c0d/1/2/6/
My expected output is just the file IDs:
72f66_59875c1ffb57b5992-b18
8823cd1-ab9532a5dc74cc904cc6bd3e2
8407fb_80bbb9c0d
I don't yet completely understand how to leverage grep to make this happen. I have been humbled.
Those look like all hex digits, so
grep -oE '/[[:xdigit:]_-]{15,}/' foo.txt | tr -d /
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
The list looks like something this:
9 vm_mail running
11 vm_webserver running
13 vm_proxy running
15 vm_wsus running
Now i only need the vm name in the middle while only using "vm" as searchterm
any ideas?
grep -Po '(?<=vm_)\S*'
gives you:
mail
webserver
proxy
wsus
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm try to make a script for checking some ethx.
If the eth is up and connected my script is working
When its not working I have a problem.
RESD=$(ssh -q vmx#$1 cat /sys/class/net/$3/dormant)
I get in RESD the following result:
cat: /sys/class/net/eth3/dormant: Invalid argument
I want to put in RESD now the first letter.
How can I do this?
Thanks
As per the comment above, this what you want to do: RESD=${RESD:0:1}? This is pure bash equivalent of RESD=$(echo $RESD | cut -c1).
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a unix assignment and What I have isnt working right. It doesnt format like the normal "cal" function.
#!/bin/bash
d=`date '+%Y'`;
$((++d));
calstr=`cal $d`;
echo $calstr;
You don't need the $ in line 2, and you need to wrap the $calstr in double quotes:
#!/bin/bash
d=`date '+%Y'`;
((++d));
calstr=`cal $d`;
echo "$calstr";