If you have no intersecting lines, use "Select by expression" with this expression including overlay_nearest()
and change the max_distance:
overlay_nearest(@layer, max_distance:=1)
Be aware: your layer must be saved in a CRS using meters as units, thus don't use a geographic CRS like EPSG:4326
(WGS84). In this case, first reproject your layer.
The two yellow lines are selected (their closest points having a distance of ca. 0.5 m), the others have a distance of more than 1 meter:
If you have lines that intersect, you have to use another expression: wehre the lines cross, the have a distance of 0 and thus would always be selected. For this reason, we want to exclude cases of lines that intersect and only consider lines that do not touch.
This can be done with this expression - change max_distance
to the distance you want and replace 100
in limit:=100
with a number that corresponds to the max. number of other lines crossing each line and add 1 (increase the number for better results, but with huge layers, it might get slow):
array_sum(
array_foreach (
overlay_nearest(
@layer,
$geometry,
max_distance:=1,
limit:=100
),
if (
length (
shortest_line(
$geometry,
@element
)
)>0,
1,
0
)
)
)