Answer the question
In order to leave comments, you need to log in
How to work with text files using sh script (Linux)?
Hello, 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
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 questionAsk a Question
731 491 924 answers to any question