Linked Questions

2
votes
1answer
153 views

Appending a variable to different lines of a file in bash [duplicate]

So say I've got a file with the following text in it. And the source file I'm reading is like this: #0 abc 2016-08-06 01:12:57 AM 9.1% 779.9M of 1G 156.3M of 1G #1 abc 2016-08-06 02:33:47 ...
1
vote
1answer
57 views

Multiple methods of inputting files [duplicate]

What is the difference between the following commands: $ input.txt > grep foo $ grep foo < input.txt $ cat input.txt | grep foo $ grep foo input.txt And not just grep. Other commands too.
0
votes
1answer
51 views

What does | symbol near end of a command do? [duplicate]

I came across someone using the command zcat [filename].gz | less to open a file. What does | generally do when it's using in this manner? I've tried googling the question but haven't found the answer ...
-4
votes
2answers
69 views

$ sh < foo > bar this statement is the question [duplicate]

What this is the following command doing? I'm new, and still learning. $ sh < foo > bar How to interpret it step by step so that I can get clear understanding more question like this.
-3
votes
3answers
60 views

What is the use of 2>? [duplicate]

What is the use of: 2> in an SSH command?
1
vote
0answers
31 views

Can't output to file with sed > [duplicate]

I'm messing around with sed for fun and have a little function I found that replaces a few characters: sed 's/"p"$/0/;s/"e"/1/' sedtext.txt Where sedtext.txt is as follows: 1, 2, 6, 7, "p" 1, 6, 7,...
0
votes
1answer
24 views

how to not-delete-a-file with some-command < file.txt > file.txt [duplicate]

I've done this before, expect to mutate a file in place, something like $ tr '\t' ',' <file.txt >file.txt and well, clearly the > redirection truncates the file before < can read it; How ...
0
votes
0answers
14 views

something wrong when overwriting file [duplicate]

I was trying to delete the last line and overwrite the file. But I failed for some reason. I could write the modified text to another file though. $cat > file.txt a b c $set "$d" file.txt > ...
166
votes
1answer
484k views

How to clean log file? [duplicate]

Is there a better way to clean the log file? I usually delete the old logfile and create a new logfile and I am looking for a shorter type/bash/command program. How can I use an alias?
119
votes
4answers
73k views

Precedence of the shell logical operators &&, ||

I am trying to understand how the logical operator precedence works in bash. For example, I would have expected, that the following command does not echo anything. true || echo aaa && echo ...
149
votes
1answer
18k views

Bash: What does “>|” do?

I have just seen this written down; $ some-command >| /tmp/output.txt Vertical pipes are used in standard redirects "piping" the output of one command to another, is >| in fact completely ...
68
votes
8answers
49k views

How can I make iconv replace the input file with the converted output?

I have a bash script which enumerates through every *.php file in a directory and applies iconv to it. This gets output in STDOUT. Since adding the -o parameter ( in my experience ) actually writes ...
53
votes
11answers
18k views

Is there a way to modify a file in-place?

I have a fairly large file (35Gb), and I would like to filter this file in situ (i.e. I don't have enough disk space for another file), specifically I want to grep and ignore some patterns — is there ...
75
votes
5answers
780k views

How to create a simple .txt (text) file using terminal? [closed]

I'm just trying to review basic terminal commands. Having said that, how do I create a text file using the terminal only?
90
votes
2answers
252k views

Bash - how to run a command after the previous finished? [duplicate]

Currently I have a script.sh file with the following content: #!/bin/bash wget -q http://exemple.com/page1.php; wget -q http://exemple.com/page2.php; wget -q http://exemple.com/page3.php; I want to ...

15 30 50 per page