Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 7072

Search thru a text file with multiple lines and extract the data from single command line

$
0
0

I am trying to search thru a text file with multiple lines and extract the data from search criteria.+

The text file, brought by boinccmd --get_tasks

name: p2030.1748699706.G46.27-03.52.N.b5s0g0.00000_3280_1
WUname: p2030.1748699706.G46.27-03.52.N.b5s0g0.00000_3280
projectURL: https://einstein.phys.uwm.edu/
received: Sun Jun 112:27:26 2025
report deadline: Sun Jun 15 12:27:25 2025
ready to report: no
state: downloaded
scheduler state:scheduled
active_task_state: EXECUTING
app version num:147
resources: 1 CPU
CPU time at last checkpoint:15632.520000
current CPU time: 15636.400000
estimated CPU time remaining: 25628.750501
fraction done: 0.383969
swap size: 134 MB
working set size: 134 MB
suspended viaGUI: no

I want to printf a report "fraction done;" and "name:" on one line on a terminal.Some text files will not contain "fraction done:" --- Those text files need to be ignored.

What I have been able to do:Get a list of "fraction done:" (Will ignore files without "fraction done:" data

for task in $(boinccmd --get_tasks | sed -n 's/\s\s\sfraction done: //p'); do printf "%s"${task}"\n"

Get a list of "name:"

for task in $(boinccmd --get_tasks | sed -n 's/\s\s\sname: //p'); do printf "%s"${task}"\n"

What I am wanting to do is get a list of:printf "fraction done: name: \n"

What I have basically tried including dozens of alternates:

for task in $(boinccmd --get_tasks | sed -n 's/\s\s\sfraction done: ,\s\s\sname: //p') | awk -F\  '{print $1,$2}'); do printf "%s"${task}"\n"; donefor task in $(boinccmd --get_tasks | sed -n 's/\s\s\sfraction done: //p'&&  sed -n 's/\s\s\sname: //p'); do printf "%s"${task}"\n"; donefor task in $(boinccmd --get_tasks | sed -n 's/\s\s\sfraction done: //p'); do printf "%s"${task}"\n"; done$(boinccmd --get_tasks | sed -n 's/\s\s\sfraction done: ,\s\s\sname: /\2/' | awk -F\  '{print $1,$2}'); do printf "%s"${task}"\n"; done

Thanks. I appreciate the help.


Viewing all articles
Browse latest Browse all 7072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>