Shell source codes post


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell source codes post
# 1  
Old 12-15-2009
Shell source codes post

Hi all,

I'm looking for a website, kind a like of http://www.planet-source-code.com to post source codes of shell scripts. Why all other languages on these websites but never the shell ? Anyone knows where to post my snippets or archives I want to share ?

Today I wrote a script which I think might be useful to many people. As you may know Python syntax is ruled not by {} but wit the indentation. The syntax analyser **** up all the time between the tabs and the spaces (IndentationError: unexpected indent). I wanted to leave this piece of code to anyone would need it. The error can be produced by the IDE pyDEV, the script cleans the code and cut out the errors.
Here it is:
Code:
#! /bin/bash

filename=$(echo $1 | sed 's/\([^.]*\)\..*/\1/')
cat $1 | sed 's/\t/    /g' > $filename.clean.py

to execute type ./script_name + python_script

Last edited by pludi; 12-15-2009 at 05:47 AM.. Reason: removed swear words and links
# 2  
Old 12-15-2009
I think they only have a limited variety of flavors, no?

BTWAFWIW, I think you could optimize your code a bit further:
Code:
filename=${1%%.*}
sed 's/\t/    /g' $filename > $filename.clean.py

Which will cut off the filename after and including the first dot
# 3  
Old 12-15-2009
Take a look at www.commandlinefu.com
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Source trigger in Unix shell

Hi All, Is ther any way to write the script with source trigger ? To trigger the script on particular time we have crontab. Similarly in a path, when a file comes particular script has to run. Thanks:) (7 Replies)
Discussion started by: jesu
7 Replies

2. Shell Programming and Scripting

Bash Shell Script Exit Codes

Here is my daily stupid question: How can I tell a script to only execute if the other scripts exits successfully? So "script A" executes and it executes successfully (0),then "script B" will run or else "script A "executes and it exits unsucessfully (1) then "script B" will read return... (6 Replies)
Discussion started by: metallica1973
6 Replies

3. Shell Programming and Scripting

HTML Codes for Shell Programs

Hi All, I need to use my script via html web page, already webserv running in my unix box... Please provide me the sample html files or any web site Thanks (2 Replies)
Discussion started by: l_gshankar24
2 Replies

4. Shell Programming and Scripting

Run Script in K Shell using Source

Hi While running a Shell Script in a K Shell using the source command source <script_name> It gives the error .. source: not found. Null message body; hope that's ok Is it that the source command does not work in K Shell. It works well in bash shell. (2 Replies)
Discussion started by: harneet2004us
2 Replies

5. Shell Programming and Scripting

Source Env file in the Shell Script

Hi I am having a script which sets the application environment. In this script i am sourcing the applications env file, when i am debugging the script i see its executing all the environment values and all the variable values are set properply. Once this main shell script executes, then... (4 Replies)
Discussion started by: umakanthly
4 Replies

6. Shell Programming and Scripting

Tidy shell script source file

Hi all, Is there a tool to tidy up shell script source file and reformat it. Preferably I am looking for a perfect tool to do this. Also I have heard it is possible to do with emacs editor but unfortunately it is looking very different and new from vi. Emacs is new to me and I could not find... (1 Reply)
Discussion started by: meharo
1 Replies

7. Shell Programming and Scripting

source code for a shell

if somebody can help me pls. i need the source code for a shell which compiles C or java programs in unix i need a very short and simple one, just the compiling part Respect (2 Replies)
Discussion started by: zlatan005
2 Replies

8. Shell Programming and Scripting

Post Shell programming: Question about source a file and read data from the file

This is shell programming assignment. It needs to create a file called .std_dbrc contains STD_DBROOT=${HOME}/class/2031/Assgn3/STD_DB (which includes all my simple database files) and I am gonna use this .std_dbrc in my script file (read the data from the database files) like this: .... (3 Replies)
Discussion started by: ccwq
3 Replies

9. UNIX for Advanced & Expert Users

Exit codes in Korn shell

Hi, Can anyone give me the explanation for the exit codes 1 and 127 returned from Korn shell. Thanks in advance. (2 Replies)
Discussion started by: miltony
2 Replies
Login or Register to Ask a Question