[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
bash

You are currently reading a thread in /g/ - Technology

Thread replies: 8
Thread images: 1
File: ss+(2016-03-23+at+07.06.46).png (4 KB, 234x68) Image search: [Google]
ss+(2016-03-23+at+07.06.46).png
4 KB, 234x68
Hi !
I'm working on a shell which delete the coments of .sh files. I can't figure how to do it :/
So I ask for help, here are the rules :
Lines starting by # have to be deleted but if there is $ or \ before it has to stay.
Thanks ! :)
>>
>>53644969

Run it by python readlines and analyze

if line starts with # or if within a line there's # and some preceding text

or get some regex master
>>
Yeah, doing it in Python wouldn't be too hard.. But I have to do it in bash :/
>>
sed -i 's/[^\\$]#//g;/^#/d' foo.sh
>>
DON'T POST FULL ANSWER OP IS TOO DUMB TO DO HIS HOMEWORK, YOU'RE NOT HIS PERSONAL TUTOR
>>
grep -Ev "\s*#.*"
>>
>>53645134
Thanks !
>>
>>53645156
Fuck off!
Thread replies: 8
Thread images: 1

[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK