Changes

Jump to navigation Jump to search
77 bytes added ,  11:04, 19 November 2019
m
Line 11: Line 11:  
  <nowiki>echo "esto es un ejemplo" | sed 's#e#R#g'</nowiki>
 
  <nowiki>echo "esto es un ejemplo" | sed 's#e#R#g'</nowiki>
   −
== Replace New Line Characters ==
+
==Replace New Line Characters==
 
  sed ':a;N;$!ba;s/\n/ /g'
 
  sed ':a;N;$!ba;s/\n/ /g'
 
This will read the whole file in a loop, then replaces the newline(s) with a space.<br />
 
This will read the whole file in a loop, then replaces the newline(s) with a space.<br />
Line 23: Line 23:  
  sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g'
 
  sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g'
   −
== Replace New Line (\n) with ", " ==
+
==Replace New Line (\n) with ", "==
 
  sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/", "/g'
 
  sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/", "/g'
    
  tr -d '\n'
 
  tr -d '\n'
   −
== Uppercase to lowercase ==
+
==Uppercase to lowercase==
 
  sed 's/.*/\L\1/g' < input
 
  sed 's/.*/\L\1/g' < input
   −
== Mongo operators to Python List ==
+
==Mongo operators to Python List==
 
  cat mongodb_operators.txt | grep -E ^\\\$ | awk '{ print "\x27" $1 "\x27" }' | sed s/\\\$//g | sed ':a;N;$!ba;s/\n/, /g'
 
  cat mongodb_operators.txt | grep -E ^\\\$ | awk '{ print "\x27" $1 "\x27" }' | sed s/\\\$//g | sed ':a;N;$!ba;s/\n/, /g'
   −
== Print some line of a file ==
+
==Print some line of a file==
 
To print line 45 from file rigodon-22011715-3.jl.ok
 
To print line 45 from file rigodon-22011715-3.jl.ok
 
  sed -n 45p rigodon-22011715-3.jl.ok
 
  sed -n 45p rigodon-22011715-3.jl.ok
Line 44: Line 44:  
To print a range and some specific file:
 
To print a range and some specific file:
 
  sed -n -e 5,8p -e 10p file
 
  sed -n -e 5,8p -e 10p file
 +
 +
== Remove empty lines ==
 +
<syntaxhighlight lang="bash">
 +
sed '/^$/d'
 +
</syntaxhighlight>

Navigation menu