Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

-1 votes
2 answers
122 views
Combine multiple lines starting with same phrase into one
I'm writing a Bash script to convert Arch Linux packages into a format for a package manager I'm writing, and I have to convert some metadata files into file format `.toml`. Previously, I've been using `sed`, but I just need something I can implement into a Bash script. The conversion should look li...
I'm writing a Bash script to convert Arch Linux packages into a format for a package manager I'm writing, and I have to convert some metadata files into file format .toml. Previously, I've been using sed, but I just need something I can implement into a Bash script. The conversion should look like shown below. Input:
... other stuff ...
depends = "some-dependency"
depends = "another-dependency"
depends = "yet-another-dependency"
Output:
... other stuff already converted ...
depends = [ "some-dependency", "another-dependency", "yet-another-dependency" ]
universeindex (7 rep)
Feb 19, 2023, 12:09 AM • Last activity: Feb 21, 2023, 08:44 PM
3 votes
3 answers
1046 views
Extract text starting at specific category header to next category header from a text file
I have a TOML file in the following format (categories may have any name, the sequential numbering is just an example and not guaranteed): ```toml [CATEGORY_1] A=1 B=2 [CATEGORY_2] C=3 D=4 E=5 ... [CATEGORY_N] Z=26 ``` What I want to achieve is to retrieve the text inside a given category. So, if I...
I have a TOML file in the following format (categories may have any name, the sequential numbering is just an example and not guaranteed):
[CATEGORY_1]
A=1
B=2

[CATEGORY_2]
C=3
D=4

E=5

...

[CATEGORY_N]
Z=26
What I want to achieve is to retrieve the text inside a given category. So, if I specify, let's say, [CATEGORY_1] I want it to give me the output:
A=1
B=2
I tried using grep to achieve this task, with the z flag, so it could interpret newlines as null-byte characters and using this regular expression:
(^\[.*])             # Match the category 
  ((.*\n*)+?         # Match the category content in a non-greedy way
    (?=\[|$))        # Lookahead to the start of other category or end of line
It wasn't working unless I removed the ^ at beginning of the expression. However, if I do this, it will misinterpret loose pairs of brackets as a category. Is there a way to do it correctly? If not with grep, with other tool, such as sed or awk.
Educorreia (225 rep)
Jul 29, 2021, 10:51 AM • Last activity: Aug 25, 2021, 06:24 PM
3 votes
2 answers
1218 views
How to use a toml lens on a single file on Ubuntu 20.04?
I need to read and modify a single file (`pcmanfm.conf`) in the current directory. I tried ``` $ augtool -At "Toml.lns incl $(pwd)/pcmanfm.conf" -I lenses/ print /files /files ``` but it does not work. `toml.aug` (on `/usr/share/augeas/lenses/dist/toml.aug`) starts with ``` (* Module: Toml Parses TO...
I need to read and modify a single file (pcmanfm.conf) in the current directory. I tried
$ augtool -At "Toml.lns incl $(pwd)/pcmanfm.conf" -I lenses/ print /files
/files
but it does not work. toml.aug (on /usr/share/augeas/lenses/dist/toml.aug) starts with
(*
Module: Toml
  Parses TOML files

Author: Raphael Pinson 
...
so I believe I put the name of the lens correctly (Toml.lns). The same setup works well if I parse file of a different type, e.g.
$ augtool -At "Shellvars.lns incl /tmp/vars.sh" -I lenses/ print /files
/files
/files/tmp
/files/tmp/vars.sh
/files/tmp/vars.sh/TESTINT = "2"
/files/tmp/vars.sh/TESTSTR = "\"FF\""
I've posted the same question on https://github.com/hercules-team/augeas/issues/699 in case it is a bug in Augeas. The file I try to parse has the following content:
[config]
bm_open_method=0

[volume]
mount_on_startup=1
mount_removable=1
autorun=1

[ui]
always_show_tabs=0
max_tab_chars=32
win_width=1916
win_height=1149
splitter_pos=150
media_in_new_tab=0
desktop_folder_new_win=0
change_tab_on_drop=1
close_on_unmount=1
focus_previous=0
side_pane_mode=places
view_mode=compact
show_hidden=0
sort=name;ascending;
toolbar=newtab;navigation;home;
show_statusbar=1
pathbar_mode_buttons=0
I want to add/replace one value in the [ui] section.
Adam Ryczkowski (5859 rep)
Oct 17, 2020, 09:52 AM • Last activity: Aug 25, 2021, 06:23 PM
1 votes
1 answers
3031 views
Podman: cannot load TOML value of type map
I need to fetch this [image][1] for podman but there is a problem on *registry.conf* podman gives error ``` podman run --name myfirstcontainer -it -v /home/jhon:/data:Z manjarolinux/base Error: error loading registries configuration "/etc/containers/registries.conf": toml: cannot load TOML value of...
I need to fetch this image for podman but there is a problem on *registry.conf* podman gives error
podman run --name myfirstcontainer -it  -v /home/jhon:/data:Z manjarolinux/base
Error: error loading registries configuration "/etc/containers/registries.conf": toml: cannot load TOML value of type map[string]interface {} into a Go slice
my registry adjust
# [[registry.mirror]]
# location = "example-mirror-0.local/mirror-for-foo"
# [[registry.mirror]]
# location = "example-mirror-1.local/mirrors/foo"
# insecure = true
# # Given the above, a pull of example.com/foo/image:latest will try:
# # 1. example-mirror-0.local/mirror-for-foo/image:latest
# # 2. example-mirror-1.local/mirrors/foo/image:latest
# # 3. internal-registry-for-example.net/bar/image:latest
# # in order, and use the first one that exists.
#
[[registry.mirror]]
prefix ="docker.io"
location = "https://hub.docker.com/r/manjarolinux/base "
insecure =true
what is wrong
maxemilian (137 rep)
Jun 21, 2021, 08:52 AM • Last activity: Aug 25, 2021, 06:14 PM
Showing page 1 of 4 total questions