A
A
Adolf Milos2019-01-12 15:31:33
linux
Adolf Milos, 2019-01-12 15:31:33

How to work with text files using sh script (Linux)?

5c39de4d4a01a322143413.jpegHello, please help me solve the following problem:
I have a text file (eg file.txt) and I want to display its contents. How to do it with a .sh script on Linux? Those. you need to create a script that, when run, the contents of file.txt are displayed on the console Tell me
where to look for information about the work of .sh scripts with text files, what commands are there, etc.
I would be very grateful for any help
PS in the photo is what I got, but it's not quite what I need

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fat Lorrie, 2019-01-12
@YAVAY

It seems you have a misprint: man cat
cat "${FILE}";

V
Vladimir Kuts, 2019-01-12
@fox_12

And what is the difficulty? Displaying the contents of a file in Linux is an elementary operation:

$ cat to_screen.sh
#!/bin/bash

cat $1

[email protected] ~
$ cat file.txt
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

[email protected] ~
$ ./to_screen.sh file.txt
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question