Hot answers tagged

3

You didn't specify an operating system. This answer assumes Windows. My first thought was a simple command such as for %f in (*.png) do rename "%f" "New_%f" But a file named a.png was first renamed to New_a.png and moved down the alphabetical order :-( The loop renamed this file a second time to New_New_a.png. Therefore, this must be done in two steps: ...


2

Create a new file containing the content as you wish it. For your situation, this can be done like this: echo "[" > database-new.json ; cat database.json >> database-new.json ; echo "]" >> database-new.json > is create new file (clearing the file if existing) and direct stdout to it. >> is append stdout to file.


2

We can place validation at the beginning of script. userid=`id -u -n` #echo "$userid" ; ownuser=`ls -l ${abosolutepath}/${your_script.sh} | awk '{print $3}'` #echo "$ownuser" ; if [ ! "$userid" = "$ownuser" ]; then echo permission denied exit 1 fi Above validation will check if the user who executing this script is same as user who own ...


1

You may want to try changing the text "SELECTION" in the later part of the script to be "SECTION" to match the first part of the script. It looks like a simple spelling issue. So, this works for me: #This is where selection offers are added or removed #echo $'\n'$SELECTIONnumberNAME echo $'\n'$SECTION1NAME echo $'\n'$SECTION2NAME echo $'\n'$SECTION3NAME


1

For a single file, the following XSLT stylesheet will do the job: <t:transform version="1.0" xmlns:t="http://www.w3.org/1999/XSL/Transform"> <t:template match="node()|@*"> <t:copy> <t:apply-templates select="node()|@*"/> </t:copy> </t:template> <t:template match="image/@alt[. = 'blah blah']"> ...


1

If your variables are all exported in the same way (export foo=bar), then you can source all of them easily using bash process substitution feature: source <(grep '^export .*=' file1.sh) Man page extract: Process Substitution Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming ...


1

There are lots of ways you can do this, but how about tr -d "\r" < input.file > output.file "tr" translates characters - in this case we use the -d switch to delete rather then replace characters, and then specify to delete the "cr" character. As tr operates using stdin and stdout, we use redirections to efficiently create a file with the new data.


1

Did you figure this out? Since your example is somewhat obfuscated, it isn't clear to me what is the \\server\share, and what is a sub-folder of the share I don't think you can use relative paths like ..\..\ to cross into another share. But it almost seems like you tried to do that. I would guess you would have gotten the correct results if you had used ...


1

This might well be the heart of the issue: The main thing to remember is that (as vulgar approximation) the "prompt" where you run your commands is a shell. When you run a script on that prompt, it is run as a sub-process of the shell. The shell becomes the parent process. Or, to quote Mendel Cooper in the Advanced Bash Scripting Guide: A subshell is ...


1

If you are already in tmux session, you can execute some command in new window like below: $ tmux neww {command} Also, if you want to split window and execute command: $ tmux splitw {command} Here's some example of running tail -f for several files in the log directory: $ find logs/ -name '*.log' | xargs -n1 -I{} bash -c 'tmux splitw "tail -f $1"; ...



Only top voted, non community-wiki answers of a minimum length are eligible