I am using this relevance to find the “nfs” present in the /etc/fstab.
(lines of file “/etc/fstab”) whose (it contains “nfs”) as trimmed string
It print the result in 1 or 2 lines depends on the number of “nfs” entry in the /etc/fstab
but I couldn’t figure out how to replace the single space " " in the result with comma “,” so that when I open the result in the CSV the result should be separated in columns.
Currently it prints the result in
server1 nasshare:/abc /mnt nfs soft,rw,bg 0
server2 nasshare:/abc /mnt nfs soft,rw,bg 0
I want the result to be in this format in separate line.
server1 nasshare:/abc, /mnt, nfs, soft,rw,bg 0
server2 nasshare:/abc, /mnt, nfs, soft,rw,bg 0
Please let me know how that will work. I have tried vaious combination of substring and concatenationbut none seems works for me.
To be clear, you don’t want to replace every space with a comma, just the spaces after the export, mount point, and type “nfs” ?
Jumping into regex I can do that as
q: (concatenation " " of (parenthesized part 1 of it ; parenthesized part 2 of it & ",";parenthesized part 3 of it & ","; parenthesized part 4 of it & ","; parenthesized part 5 of it; parenthesized part 6 of it))of matches(regex("(^[^[:space:]]*)[[:space:]]*([^[:space:]]*)[[:space:]]*([^[:space:]]*)[[:space:]]*([^[:space:]]*)[[:space:]]*([^[:space:]]*)[[:space:]]*([^[:space:]]*)[[:space:]]*")) of lines containing "nfs" of file "c:\temp\test.nfs" as trimmed string
A: server1 nasshare:/abc, /mnt, nfs, soft,rw,bg 0
A: server2 nasshare:/abc, /mnt, nfs, soft,rw,bg 0
If we were to replace all the spaces it’s much easier
q: (concatenation ", " of substrings separated by " " of it ) of lines containing "nfs" of file "c:\temp\test.nfs" as trimmed string
A: server1, nasshare:/abc, /mnt, nfs, soft,rw,bg, 0
A: server2, nasshare:/abc, /mnt, nfs, soft,rw,bg, 0
Thanks Jason appreciate your help.
The “fstab” has “tab” or “space” between the nasshare and mount pt. It’s not consistent what fstab has, it could be tab or “space”.
If I use this query. It add “%90” character.
(concatenation ", " of substrings separated by " " of it ) of lines containing “nfs” of file “/tmp/fstab” as trimmed string.
The “regex” expression doesn’t completely remove the “space” or “%90”.
I did this to remove “space” or “%90”.
(concatenation “,” of substrings separated by " " of it) of (concatenation " " of substrings separated by “%09” of it) of ((lines of file “/tmp/fstab”) whose (it contains “nfs”) as trimmed string)
regards
S
sorry its “%09” instead of “%90”