like what?
Type: Posts; User: ghostdog74; Keyword(s):
like what?
Have you read the link "Effective awk" in my sig? awk is little language that provides you with the basics for programming, arrays, variables, functions, if/else, switch etc. What can it program ?...
Use awk. It has the advantage of getting rid of empty lines for you AND if you need other processing on other lines, it will do that for you too.
#remove empty lines
awk 'NF' file
for...
that was just a poor example.. You can see geirha's example. (@geirha's thanks,been dormant for a while and forgot about FILENAME). Sorry what point are you proving again?
when it comes to...
don't forget, -exec is an option for the find command
find . -type f -name "file" -exec awk '{gsub(/replace/,"new")}1' "{}" > temp \; -exec mv temp "{}" \;
true, awk doesn't have in place...
You only need to learn awk out of sed/awk. Forget about sed. With awk, you can do what sed does , and much more, because Awk is a programming language itself. If you want to get more in depth on awk,...
no, that will not.
there are 2 notions to "removing lines". One is actual removal from the file itself. Another is just not printing them out (and redirecting those printed to another file)
awk (not printing them...
there are many other ways to do it
awk
awk '/^\/var\/mobile\/Application.*\.app$/' file
sed
this a more rubyish
n = ARGV[0].to_i
n.upto(1000) do|x|
puts x
end
provided there's no floating point numbers.
is your caps lock ALWAYS going to be ON? type a character on your terminal, if its CAPs, then turn it off. Why do you need a script for that?
next time, show your expected output as well
awk 'NR>1{$1=($1>20)?$1-5:$1+5;print}' file
awk '/success/&&!f{v=$0;f=1}/success/{last=$0}END{print v;print last}' file
use awk, as shown, or you can just the shell without calling external commands.
var="1 2 3 4 5"
set -- $var
echo "$5 $3"
Its a Python question. Why the Perl stuff?
if you want to use Python, then use Python. Why mix shell and Python together? Unless you really have no choice, then do it this way. It makes your code non portable.
for file in...
It could have been written this way, without the need for calling external expr.
x=0
finish=100
while [ $x -le $finish ]
do
echo $x
((x++))
done
wrong
and wrong.
@OP
your problem is , brace expansion is performed before any other expansions.
....
Bash is useless when it comes to floating points, if your number of lines is odd, that is.
you should really learn how to use awk instead
awk 'END{print NR/2}' file
that's it.
and what if the pattern is like
# echo "AAAABBCBBCCCCAAAADDDD" | sed -e :a -e '/AAAA.*CCCC/{s/CCCC//;s/AAAA//;ta}'
BBCBBAAAADDDD <<----wrong
# echo "AAAABBBBCCCCAAAADDDD" | awk...
yes, i do mean it in general. And yes, i still stand by my point of view. There is no need to learn sed at all. awk does what sed does, and a lot more. See http://awk.info for some projects done with...
what if the pattern is
AAAABBCBBCCCCAAAADDDDCCCC ?
the output should be
BBCBB
# echo "AAAABBCBBCCCCAAAADDDDCCCC" | awk 'BEGIN{RS="CCCC";FS="AAAA"}RT{print $2 }'
BBCBB
DDDD
Forget about sed, use awk. They both have the same capabilities, BUT awk is more powerful since its also a programming language.
$ echo "AAAABBBBCCCCAAAADDDDCCCC" | awk...