13
votes
1answer
2k views

Ruby escape ARGV argument or string as argument to shell command

Ok this is driving me crazy: `ls #{"/media/music/Miles Davis"}` fails because of the space between "Miles" and "Davis" Say I write a ruby script and a user passes file path as an argument. How do ...
5
votes
3answers
429 views

<script> tag must include separate </script> tag?

Excuse the poor title for my question, I'm not sure how to ask this. I noticed today while doing some testing that the way I close my <script> tag either makes or breaks my page. For example, ...
5
votes
2answers
53 views

Technical name for code not part of any function

What would be the technical term for code in scripting languages which is not part of any function and is executed first when the script is imported? For example, in python: import anything #what ...
4
votes
1answer
444 views

What is the meaning of ${0%/*} in a bash script?

I am trying to understand a test script, which includes the following segment: SCRIPT_PATH=${0%/*} if [ "$0" != "$SCRIPT_PATH" ] && [ "$SCRIPT_PATH" != "" ]; then cd $SCRIPT_PATH fi ...
4
votes
2answers
4k views

Script to rename files

I have about 2200 different files in a few different folders, and I need to rename about about 1/3 of them which are in their own subfolder. Those 700 are also in various folders as well. For ...
4
votes
3answers
133 views

Creating a bash script that acts as a fortune teller or “magic 8 ball” essentially

I am trying to create a bash script that is essentially like a magic 8 ball with 6 different responses (Yes, No, Maybe, Hard to tell, Unlikely, and Unknown). The key is that once a response is given, ...
3
votes
11answers
167 views

simple jquery code. I don't know what I'm doing wrong

Ok. First let me say that I just started learning jQuery and I've taken various challenges upon myself so I can learn faster. Today, I have a very novice question, so apologies if the answer to this ...
3
votes
2answers
1k views

evaluating lines from stdout

I have a bash script that is executing a program in a loop. I want to evaluate each line from the stdout and do something if it matches my condition. I still want to be able to see stdout on the ...
2
votes
4answers
634 views

What are use cases for Groovy Scripting besides Java / Groovy classes?

I am playing around with Java, Groovy and Scala at the moment. Groovy enables to write scripts besides classes, which is often stated as a big advantage of Groovy because you can write applications ...
2
votes
3answers
110 views

Who defines %cd% for my batch?

The following batch script prints out my current working directory. echo %cd% But I didn't define the cd variable. So who does this? Is there anything else like this? I also checked the ...
2
votes
4answers
1k views

linux - How can I run a function from a script in command line?

I have script that has some functions. Can I run one of the function directly from command line? something like myScript.sh func() ?
2
votes
5answers
77 views

How to extract a particular pattern from a file?

I have a file as in below format: #### >>> start of File Item number - 1 Name xxxx yyyy Result PASS Item number - 2 Name yyyyy yyyy Result FAIL Item number - 3 NAME ppppp eeee rrrrr ...
2
votes
2answers
147 views

Is it possible to set Powershell profile code to run after every script?

I have set up a Powershell profile to run at Powershell startup. Is it possible to configure powershell to call the profile after every .ps1 script so I don't have to call .$profile at the end of ...
2
votes
4answers
98 views

unix script error

I have the following line in my unix script file: if [[ -f $DIR1/$FILE1 ] -a [ -f $DIR1/$FILE2 ]]; then As clear the line checks for existence of two files in a directory and if both the files are ...
2
votes
2answers
841 views

Shell scripts and the md5/md5sum command: need to decide when to use which one

First time poster, here, so go easy on me. :) Pretty sure nobody's yet asked this in researching this question. Short version: How can I tell a shell script to use one command versus the other, ...

1 2 3 4 5 8
15 30 50 per page