I refuse to attempt to do 1-liners where I can't see what it is doing. And, with no sample variable values and no sample data to work on and no description of the expected output, this is obviously totally untested, but should come close to what your unreadable pipeline did:
I think that the expression NR - ndel keeps track of the NR value that would have been seen in the second awk script. Without understanding what the shell variables BEFOREGLAF and AFTERGLAF are doing in your script, I have no idea whether or not any of the ndel calculations are needed as is, could be simplified by changing those two shell variables, or could just be skipped entirely.
These 2 Users Gave Thanks to Don Cragun For This Post:
As a general remark about one-liners: one-liners reduce readability and understandability. Their advantage is that they can be fastly written.
Given that you are unable to modify your already existing one-liners (which i take as a hint that you are not completely understanding them already) i suggest that it is a bad idea to combine these to an even more complex construct which you are bound to understand even less.
It is of course always possible to rely on us (or other people like us) to provide modifications as the code will need to be modified but, honestly: do you really want to preside over an environment where you do not understand what is going on? It might be me but i for my part would have a very bad feeling being in such a position.
It is in your own best interest if you rely on us only if you need an explanation to further your understanding but not to write or modify your productive code. Whatever you use finally you should be able to produce on your own and you should write it in a way that you are able to understand its inner workings.
Btw., over time i found that restricting my written code to 80 characters per line with only select few exceptions (for instance definitions of string constants) makes my code more readable and better overall. The reason is that a line containing more than 80 characters is most likely badly formed and should be rewritten in a more conclusive manner anyways. This in most cases means i reformat one-liners to their long form.
Here is an example where i filter out comments and whitespace from an input file before processing:
Going over that code i modified it to:
I'd say the second variant gives you a much cleaner and easier to grasp impression of what is going on than the first.
Hi,
Can someone please guide me how to combine the following two awk calls in one?
I noticed that it is very often situation for me, and I think that it can be replaced with one awk call.
The question is more general, not the exact one.
echo "A B C/D" | awk '{print $3}' | awk -F/ '{print... (4 Replies)
I have the following sh-script:
konsole -T todo -e vi todo.txt &
konsole -T window1 -e ssh user@server &
konsole -T window2 -e ssh user@server2 -e cd directory &
The first two lines are working fine. The first opens a txt-file, the second opens a ssh-connection.
The third line... (6 Replies)
What is the correct syntax to pipe or run three awk commands? Basically, using the output of the first awk as input in the second. Then using the output of the second awk in the third. Thank you :).
awk 'FNR==NR {E; next }$3 in E {print $3, $5}' panel_genes.txt RefSeqGene.txt > update.txt |... (3 Replies)
Dear friends,
I am just trying write one script using 2 files
one file will contain details like below
#X SERVER X LOCATION
URL="http://www.abcd.com"
FILENAME="abc.txt"
ID_NAME="myabc_xyz"
SERVER_PATH="/usr/local/dummy/html/....."
#Y SERVER Y LOCATION
URL="http://www.xyz.com"... (10 Replies)
sed -e :a -e 's/<*>//g;/</N;//ba' a2.html -removes html tags
and
sed -i 's/YOURS TRULY/Joe Bob/' a2.html
Replaces a string with another string
can i make it into one string? (2 Replies)
How would I combine two nawk commands together without calling up nawk twice. Just like the sed -e command
nawk '$3>=from&&$3<=to' from="$STIME" to="$ETIME" | nawk '{$5="";$6=""}1' (2 Replies)
Hi,
i tried to combine grep with find and it didnt work
grep 'find dirname filename"
i also would like that the file will be sorted in the way.
thanks a lot. (2 Replies)
How i can combine output of two commands in one file.......i tried this but it is not working although each command is working good seperately.....
head -1 filename | tail -1 filename
i think there is problem with command concatenator? (16 Replies)