You are not logged in.

#1 2019-01-03 11:50:46

makh
Member
Registered: 2011-10-10
Posts: 305

[Solved] How to read/open Multiple Text files fastly

Hi

The image viewer is pretty fast, as it opens the next image files.

I have a 300+ files folder. Is it possible to read these small files like an image viewer?


thankyou

Last edited by makh (2019-01-14 03:28:22)


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#2 2019-01-03 12:09:43

bugsmanagement
Member
Registered: 2017-04-21
Posts: 201

Re: [Solved] How to read/open Multiple Text files fastly

Hello,

There isn't any context in this request, are we suppose to know what you are talking about?

Regards

Offline

#3 2019-01-03 13:35:24

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,682

Re: [Solved] How to read/open Multiple Text files fastly

for name in *; do echo "$name"; cat "$name"; echo "=========================================="; done | less

Shows all files in one pager, but bugsmaangement is right: you need to be more precise on what you expect.
Also read into some bash basic tutorials.

Offline

#4 2019-01-03 13:38:44

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: [Solved] How to read/open Multiple Text files fastly

@makh, I afraid to lie you, but it seems that `ranger` file manager allow to do what you want.

Last edited by Kirill Bugaev (2019-01-03 15:10:57)

Offline

#5 2019-01-03 17:36:21

makh
Member
Registered: 2011-10-10
Posts: 305

Re: [Solved] How to read/open Multiple Text files fastly

Kirill Bugaev wrote:

@makh, I afraid to lie you, but it seems that `ranger` file manager allow to do what you want.

Hi
Its excellent, for English. But I will also need to learn it.

But ranger doesnt supports my other languages Urdu/Arabic, unfortunately!

I was thinking of some idea to convert all to image files or perhaps join into one document file. But it doesnt seem so nice.

For a while ranger will do!

Thanks a lot


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#6 2019-01-03 17:38:46

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,682

Re: [Solved] How to read/open Multiple Text files fastly

ranger doesnt supports my other languages Urdu/Arabic

Errrr… what?
If it's some text, you can display it - maybe you need a monospace font w/ better utf-8 coverage?

Offline

#7 2019-01-03 17:39:21

makh
Member
Registered: 2011-10-10
Posts: 305

Re: [Solved] How to read/open Multiple Text files fastly

bugsmanagement wrote:

Hello,

There isn't any context in this request, are we suppose to know what you are talking about?

Regards

Hi

Actually I made a lot of files on some important notes. Those points are now scattered in a huge volume of files. It looked cute and easy in the start, but not any more.

Sorry! I didnt explain well.

Now I have issue in slow opening and viewing of files. But ranger solves my issue by 50%.

Thankyou


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#8 2019-01-03 19:50:43

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,531
Website

Re: [Solved] How to read/open Multiple Text files fastly

#!/bin/sh

tmpfile=/tmp/my_notes.html

cat <<EOF >| $tmpfile
<!DOCTYPE html>
<html>
<head>
<title>Overview of files in $1</title>
</head>
<body>
EOF

for f in $(find $1 -maxdepth 1 -type f -name '*.txt'); do
   printf '<h1>%s</h1><pre>' "$f" >> $tmpfile
   cat "$f" >> $tmpfile
   printf '</pre>' >> $tmpfile
done

cat <<EOF >> $tmpfile
</body>
</html>
EOF

$BROWSER $tmpfile

Pass this script the directory you want to check and it will open all the files in one page in your browser assuming BROWSER is set, replace that as needed.  Also adjust the find command as needed to include all the files you want and no others.  Add any css you want in the html of the script.

Last edited by Trilby (2019-01-03 19:52:23)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#9 2019-01-03 21:48:43

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: [Solved] How to read/open Multiple Text files fastly

@Trilby, thanks a lot for script, but it doesn't support files with spaces in name. For example, if I have "/data/howtos/AUR upgrade.txt" file, parts "/data/howtos/AUR" and "upgrade.txt" will be consistently assignment to `f` variable and shell will evaluate them as two different files. Maybe this will be more suitable.

#!/bin/sh

tmpfile=/tmp/my_notes.html

cat <<EOF >| $tmpfile
<!DOCTYPE html>
<html>
<head>
<title>Overview of files in $1</title>
</head>
<body>
EOF

#for f in $(find $1 -maxdepth 1 -type f -name '*.txt'); do
for f in "$1"/*.txt; do
   printf '<h1>%s</h1><pre>' "$f" >> $tmpfile
   cat "$f" >> $tmpfile
   printf '</pre>' >> $tmpfile
done

cat <<EOF >> $tmpfile
</body>
</html>
EOF

$BROWSER $tmpfile

Last edited by Kirill Bugaev (2019-01-03 22:03:14)

Offline

#10 2019-01-03 21:49:29

Kirill Bugaev
Member
Registered: 2018-08-03
Posts: 173

Re: [Solved] How to read/open Multiple Text files fastly

deleted

Last edited by Kirill Bugaev (2019-01-03 21:49:52)

Offline

#11 2019-01-03 21:53:17

HalosGhost
Forum Fellow
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,097
Website

Re: [Solved] How to read/open Multiple Text files fastly

Kirill Bugaev wrote:

deleted

Do not do this. Read the full Code of Conduct before you post again.

All the best,

-HG

Offline

#12 2019-01-03 22:03:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,531
Website

Re: [Solved] How to read/open Multiple Text files fastly

Oops, yes, this is better:

find "$1" -maxdepth 1 -type f -name '*.txt' | while read f; do

Find is handy as you can do more complex filtering and/or include sub-directories.  But if none of that is needed, use whatever works.  I don't actually use such a script.  If I want to find a specific file in a set of files with some text in it, I don't eyeball them, I use `grep -l $pattern`.

Last edited by Trilby (2019-01-03 22:05:02)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#13 2019-01-03 22:08:33

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,682

Re: [Solved] How to read/open Multiple Text files fastly

Untested, probably some escape errors ;-)

find $1 -maxdepth 1 -type f -name '*.txt' -exec printf '<h1>%s</h1><pre>' {} >> $tmpfile \; -exec cat "{}" >> $tmpfile \; -exec printf '</pre>' >> $tmpfile \;

Offline

#14 2019-01-03 22:40:15

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: [Solved] How to read/open Multiple Text files fastly

Note that "find" does not sort in the usual lexical manner. If OP requires the files to be output in an intuitive order, any output from find will need to be piped through "sort" first

Offline

#15 2019-01-10 11:46:34

makh
Member
Registered: 2011-10-10
Posts: 305

Re: [Solved] How to read/open Multiple Text files fastly

Hi

Trilby wrote:

Oops, yes, this is better:

find "$1" -maxdepth 1 -type f -name '*.txt' | while read f; do

This fails to work! I get nothing as output.

@Seth:

find $1 -maxdepth 1 -type f -name '*.txt' -exec printf '<h1>%s</h1><pre>' {} >> $tmpfile \; -exec cat "{}" >> $tmpfile \; -exec printf '</pre>' >> $tmpfile \;
bash: $tmpfile: ambiguous redirect

No results..!

Thankyou


OS:  Arch  &/  Debian
System: LENOVO ThinkPad E14
Desktop: Xfce

Offline

#16 2019-01-10 13:15:22

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,682

Re: [Solved] How to read/open Multiple Text files fastly

Yeah, "tmpfile" is a variable in Trilby's script - please don't randomly copy&paste stuff into your shell.

Offline

#17 2019-01-10 14:38:55

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,531
Website

Re: [Solved] How to read/open Multiple Text files fastly

And $1 is a positional parameter assuming you'd put this in a script and pass the script a path/directory.

EDIT: and more importantly, that line was not a complete command but an excerpt/revision of the previous script.  On it's own it's obviously incomplete.

Last edited by Trilby (2019-01-10 19:29:37)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB