You could use a command-line editor such as sed
sed 'N;N;N;s/\n/\t/g' file > file.tsv
or, more programatically, by adding backslash line continuation characters to each of the lines you want to join using GNU sed's n skip m
address operator and following it with the classic one-liner for joining continued lines:
sed '0~4! s/$/\t\\/' file | sed -e :a -e '/\\$/N; s/\\\n//; ta'
See for example Sed One-Liners Explained :
Append a line to the next if it ends with a backslash "\".
sed -e :a -e '/\\$/N; s/\\\n//; ta'
However IMHO itwould be easier with one of the other standard text-processing utilities e.g.
paste - - - - < file > file.tsv
(the number of -
will correspond to the number of columns) or
pr -aT -s$'\t' -4 file > file.tsv
(you can omit the -s$'\t
if you don't mind the output to be separated by multiple tabs).
The strange re-import behavior that you are observing is almost certainly because the original file has Windows-style CRLF line endings. If you need to work with files from Windows, then you can roll the conversion into the command in various ways e.g.
tr -d '\r' < file.csv | paste - - - -
or
sed 'N;N;N;s/\r\n/\t/g' file.csv
The former will remove ALL carriage returns whereas the latter will preserve a CR at the end of each of the new lines (which may be what you want if the intended end user is on Windows).
Best Answer
Unfortunately, no, it is not possible to pass a relative path with this
admin://
URI. This answer may be disappointing, but that is how it currently (Ubuntu 18.04, Ubuntu 19.10) works.Using a short wrapper script
You can, however, very conveniently work around the issue with a wrapper script. With the script
sedit
, you edit a file correctly with administrator privileges, just by typing the command and a filename, as insedit ubuntu.css
.sedit
):If you place that in a folder in your path, the command
sedit ubuntu.css
will open the file using the admin URI. Also providing the full path, or any valid path, will work.Other options
Other, more standard options to not to have to type the pathname are:
You can use Tab expansion once you typed the three slashes of the URI.
You could drag the file from Files (nautilus) into the terminal. Thus, you could type "gedit admin://' in the terminal, find the file in Files, and then drag the file from Files into the terminal. This can make it easier to enter the URI in the terminal.
You could avoid typing the path using
$(pwd)filename
or$(readlink -f filename)
.or
You can install the nautilus python extension,
nautilus-admin
. Install it with the commandsudo apt install nautilus-admin
or using Synaptic Package manager (unfortunatelly, you cannot find it using Software). This small python extension integrates in the right-click menu, and converts the selected file to an 'admin://' URI for editing with root permissions.