|
I'm writing a bash script that involves a long series of pipes. I also want to make it readable. Is there a simple way to put these on multiple lines and making bash treat it as one single line of input? code:
|
# ¿ Feb 28, 2008 17:28 |
|
|
# ¿ Apr 29, 2024 12:35 |
|
6174 posted:What you are looking for is called a line continuation character. In the case of bash it is \ Oh yes it is. My error was caused by something else.
|
# ¿ Feb 28, 2008 18:11 |
|
Here's my very ugly take on it! echo "16(100%)" |sed 's/[()%]/ /g'|awk '{print $2}'
|
# ¿ Feb 28, 2008 20:28 |
|
I'm making a bash script where I need to echo $VARIABLE number of something on a line, let's say Xs. Like this, the unknown command is [?]: alice=5 bob=7 echo "Alice [?]" echo "Bob [?]" ...and get this output: Alice XXXXX Bob XXXXXXX
|
# ¿ Mar 7, 2008 20:53 |
|
Plastic Jesus posted:I totally misread this and thought that you wanted to print the number of characters in a string. Which is actually awesome because I learned how to find out the length of a string in bash (it's ${#var_name} btw). That was exactly what I needed. That get lenght of a string thing will be very useful for me too. I did that by stringlength=`echo $string | wc -l`
|
# ¿ Mar 9, 2008 16:25 |
|
In bash, is there a way to redirect stdout to a command that works on files? I have a list that I'd like to compare to another list using comm. One of the lists is created by a [long tangle of seds, awks and greps], while the other is a file (mylist). The command comm only takes input as files. Do I have to go by a temp file, or is there some way to get comm to work with the stdout? from: [long tangle of seds, awks and greps] >tempfile comm tempfile mylist to: comm mylist [long tangle of seds, awks and greps]
|
# ¿ Mar 14, 2008 22:30 |
|
floWenoL posted:Yes. You want "comm mylist <(long tangle of seds awks and greps)". Under the hood, bash replaces <(...) with something like /dev/fd/XXX which is the dev path to the stdout of the process. Thank you! This is extremely useful. I haven't seen this in any of the many bash tutorials/tips/tricks I've seen online. This is as useful as 2>&1 !
|
# ¿ Mar 17, 2008 19:42 |
|
|
# ¿ Apr 29, 2024 12:35 |
|
This is a bash/shellscript question: I have file with lots of DNA sequences in them. Missing letters are replaced by -s. They look like this: -----AACGCT--TTGGT-- -GG-TAACGCT--TTGGT-- TGG-AACGCT---TTGGTCC I want to replace the leading and trailing, but not internal, -s of each line with ?s to get this result: ?????AACGCT--TTGGT?? ?GG-TAACGCT--TTGGT?? TGG-AACGCT---TTGGTCC Finding the leading and trailing -s is an easy regexp ( ^[-]* and [-]*$ ), but is there an efficient way to replace them with the same number of ?s ? Now I'm using a horrible and slow sed script to do that. code:
|
# ¿ Mar 31, 2008 17:48 |