Tag Info

Hot answers tagged

3

#/bin/bash if [ "$SourceFile" -nt "$TargetFile" ]; then echo "SourceFile is newer than Targetfile" fi -nt means "newer than". I've added quotes around the file names because if you need quotes on the echo, tehn you also need quotes on the file names...


3

You can do this with grep's -B (--before-context) option: grep -B 20 error filename


2

To run vlc as another user, use: #!/bin/sh su user -c 'vlc -vvv bigbuck.mp4 --sout "#rtp{dst=99.195.203.99,port=8090,sdp=rtsp://99.195.203.99:8091/test.sdp}" & If you don't need the graphic interface, you might consider using cvlc in place of vlc: #!/bin/sh su user -c 'cvlc -vvv bigbuck.mp4 --sout ...


2

this answer might cover it Spaces in Linux environmental variables? You put the environment variable in double quotes. example demonstrating that below I am doing ls 'asdf asdf' which is ls on one file 'adsf asdf' with a space in the filename. I want to do it with a variable. You see with double quotes it gets the result. With no quotes it treats the space ...


1

Loops are run as a separate process so variables inside a loop are destroyed when the loop ends. If you can use Python, it does keep variable changes inside loops. currd = ["dir1"] is_this = "n" datalines = ["dir1"] print is_this # checking variable for lines in datalines: if lines != "".join(currd): print lines + " is not current dir" ...


1

@echo off for /F %%i in ('dir /b /a:d') do ( dir /b /d %%i\build 2>NUL && echo rmdir /q /s %%i ) Remove the echo before rmdir if you find that it does what you want? WARNING this is a bit untested so be careful maybe better to echo to a file and run from there after edit.


1

If I am interpreting your question correctly I believe you are asking how to force a pseudo-tty allocation when opening the ssh connection. this should do what you want : ssh -t root@hostname 'su - dba' Not sure why you need that....



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