Tag Info

New answers tagged

0

Will strip also empty lines grep -E -v "^\s*($|;)" php.ini


5

Get rid of the commas in the userid list. The way to pass a list to a for loop is to give it space separated values, not comma separated: for userid in 234, 283, 893, 982, 323; do echo "$userid";done prints 234, 283, 893, 982, 323 But for userid in 234 283 893 982 323; do echo "$userid";done prints 234 283 893 982 323 So, you should do for ...


1

You need to single quote your here document limit string, otherwise parameter substitution will be enabled. This should work: #!/bin/bash cat server | while read line do /usr/bin/sshpass -e ssh -t -q -o StrictHostKeyChecking=no root@$line <<'EOF' echo successfully logged in $line MYIP=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet ...


3

POSIX defines the sort utility's purpose so: Sort lines of all the named files together and write the result to the specified output. You can sort two files into a concatenated output file like: sort $opts file1 file2 >output_file If you want to see the output on your shell's stdout and save the results in an output file then use tee: sort ...


7

You have already redirected the output of file1 and file2 to the new file file3. With this command cat file1 file2 > file3 | sort, sort after pipe. This could be verified as below. cat file1 A Z B cat file2 F G C Now when I run the command as, cat file1 file2 > file3 | sort we could see that the contents of file1 and file2 are written to file3 ...


0

I do this often enough and so wrote this script. I don't need to find the line numbers, the script does it all. #!/bin/bash # $1: start time # $2: end time # $3: log file to read # $4: output file # i.e. log_slice.sh 18:33 19:40 /var/log/my.log /var/log/myslice.log if [[ $# != 4 ]] ; then echo 'usage: log_slice.sh <start time> <end time> ...


4

It's not just ^M. Every byte with a non-printable character (whatever that means in your current locale) will be expanded to a multiple-byte printable equivalent under cat -v. If you're using cat to join files, you need to avoid every option that modifies the output: -b and -n (number lines), -E (mark line endings with $), -s (suppress repeated empty ...


1

Your analysis sounds correct to me. I would use cat to join files, since that's its primary function. Just do so without the -v switch, or any switches for that matter. Using cat -v .. on the file has essentially trashed it. Did you try and open it in an image viewer? I tried your method and that's exactly what happened to mine. You can see the evidence of ...


1

I prefer the following method... cat example.txt ; echo This doesn't doesn't evaluate the contents of example.txt or occasionally add a newline. It just echos a newline once the cat is done, is easy to remember, and no one is thinking about whether they're using strong or weak quoting correctly. The only downside, really, is that you'll get an extra ...


0

Do this instead: #!/bin/bash gzip -d $1 && gzip -d $2 1A=`sed 's/.gz//g` 2A=`sed 's/.gz//g` cat $2A >> $1A gzip -c $1A > $1A.gz Invocation: $> bash yourNewScriptIMadeForYou file1.gz file2.gz Explanation Line 1 Declares Environment as Bash. Line 2 Invokes GZIP [-d] to extract archive, "&&" operator means "DO THIS and THEN ...


0

Try: tar -cvzf fastq.tar.gz /path/to/all/fastqs/*.gz Or are you trying to skip the tar?



Top 50 recent answers are included