tracing multi-line commands in bash [closed] - bash

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

Related

grep for a string from URLs of different lengths [closed]

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 /

How to write a file in ruby without a terminating newline [closed]

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 7 years ago.
Improve this question
For debugging purposes, I want to alter a rake test so as not to end a saved file with a newline.
I don't know ruby. How do I do this? (file.print doesn't seem to work.)
Not clear what you are doing, but since you tried file.print, it looks like you have access to what is to be printed. Let's say this is string. My guess is that string already has a newline character. Then do:
file.print(string.chomp)

cutting a particular part of a line without using grep command [closed]

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

Reuse of the same variable wit using echo and cut [closed]

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).

Unix: Trying to increment a calender year and display [closed]

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";

Resources