![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| spacing problem | darkhider | Shell Programming and Scripting | 2 | 11-28-2008 03:57 AM |
| How to adjust spacing | stevefox | Shell Programming and Scripting | 4 | 03-29-2007 09:19 AM |
| character spacing issue | wxornot | Shell Programming and Scripting | 1 | 03-08-2006 08:22 PM |
| Complex Pipeline/Redirection/Regular Expression problem | netmaster | UNIX for Dummies Questions & Answers | 1 | 11-29-2005 12:55 AM |
| spacing question | vivekshankar | UNIX for Dummies Questions & Answers | 7 | 05-22-2005 11:34 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Double Spacing complex sed pipeline
my script: Code:
FILE="$1"
echo "You Entered $FILE"
if [ -f $FILE ]; then
tmp=$(cat $FILE | sed '/./!d' | sed -n '/regex/,/regex/{/regex/d;p}'| sed -n '/---/,+2!p' | sed -n '/#/!p' | sed 's/^[\
]*//' | sed -e\
s/[^:]*:// | sed -n '/==> /!p' | sed -n '/--> /!p' | sed -n '/regex/,+1!p' | sed -n '/======/!p' | sed -n '/regex/!p' | sed -n '\
/regex/!p' | sed -n '/regex /!p')
fi
MyVar=$(echo $tmp > my.txt)
FILE2="$2"
if [ -f $FILE2 ]; then
tmp2=$(cat $FILE2 | sed -n '/regex/,/regex/{/regex/d;p}' | sed -n '/#/!p' | sed -e s/[^:]*:// | sed /--------/,+10d)
fi
echo "You Entered $FILE2"
MyVar2=$(echo $tmp2 > my2.txt)
var=$(echo hi2.txt | sed '/^$/p' )
echo "$var"
cmp -b my.txt my2.txt
i know, i know. thats a long pipeline..my problem is that i cant seem to include anywhere in it to be able to double space it. sed G sed '/^$/p' or awk, they just really doesnt register. the sed pipeline is to long for me to do that.. .. Anyways , what i have looks similar to the paragraph that i just typed. And probably this one when im through. the exception to this and my text file is that it has valid commands. nothing else. So it makes sense for me double space the file iim talking about and then somehow to use a loop to execute each line ( contaiing the comands ) . i really struck. i really need help. |
|
||||
|
Hi, it is hard to understand your many sed commands. Perhaps you can give us an example of what you have and what you want to achieve. If would combine your first sed-command to delete all blank lines and double-space the rest at the same time. Code:
sed '/./!d;/./{G}' test
Note: You don't need cat. Sed can take a file as argument. Secondly you don't need to call sed multiple times which slows down execution speed. You can execute many commands in one sed call, simply separate them by ";" as in the example above. Or you write a sed script and call it with the "-f" option. HTH Chris |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|