Skip to main content
Filter by
Sorted by
Tagged with
346 votes
9 answers
370k views

How can I write multi-lines in a file called myconfig.conf using BASH? #!/bin/bash kernel="2.6.39"; distro="xyz"; echo <<< EOL line 1, ${kernel} line 2, line 3, ${distro} line 4 line ... ...
user avatar
346 votes
8 answers
269k views

I need to create a zip file using this command: zip /dir/to/file/newZip /data/to/zip/data.txt This works, but the created zip file creates a directory structure mimicking the directory to the raw ...
Jake's user avatar
  • 4,404
345 votes
7 answers
290k views

I'm looking to run a Linux command that will recursively compare two directories and output only the file names of what is different. This includes anything that is present in one directory and not ...
barfoon's user avatar
  • 28.4k
340 votes
12 answers
438k views

If I run these commands from a script: #my.sh PWD=bla sed 's/xxx/'$PWD'/' ... $ ./my.sh xxx bla it is fine. But, if I run: #my.sh sed 's/xxx/'$PWD'/' ... $ ./my.sh $ sed: -e expression #1, char 8: ...
RomanM's user avatar
  • 6,771
339 votes
4 answers
193k views

Should or should I not wrap quotes around variables in a shell script? For example, is the following correct: xdg-open $URL [ $? -eq 2 ] or xdg-open "$URL" [ "$?" -eq "2"...
Cristian's user avatar
  • 7,227
337 votes
8 answers
401k views

I run this command to find and replace all occurrences of 'apple' with 'orange' in all files in root of my site: find ./ -exec sed -i 's/apple/orange/g' {} \; But it doesn't go through sub ...
hd.'s user avatar
  • 18.4k
336 votes
7 answers
230k views

Both nohup myprocess.out & or myprocess.out & set myprocess.out to run in the background. After I shutdown the terminal, the process is still running. What's the difference between them?
Yarkee's user avatar
  • 9,480
329 votes
10 answers
769k views

I have a bunch of servers, on which I run experiments using screen. The procedure is the following : ssh to server XXX launch screen start experiments in a few tabs detach screen disconnect from the ...
Wookai's user avatar
  • 21.9k
323 votes
13 answers
337k views

I have a python script that'll be checking a queue and performing an action on each item: # checkqueue.py while True: check_queue() do_something() How do I write a bash script that will check if ...
Tom's user avatar
  • 44.9k
321 votes
12 answers
234k views

I'm running Debian on Windows 10 (Windows Subsystem for Linux) and installed Rust using the command: curl https://sh.rustup.rs -sSf | sh There were no errors in the install, but when I tried to ...
Thane Plummer's user avatar
319 votes
17 answers
731k views

I'm running a nohup process on the server. When I try to kill it my putty console closes instead. this is how I try to find the process ID: ps -ef |grep nohup this is the command to kill kill -9 ...
user2535056's user avatar
  • 4,243
317 votes
14 answers
578k views

Is there a "goto" statement in Bash? I know it is considered bad practice, but I need specifically a "goto".
kofucii's user avatar
  • 7,713
315 votes
9 answers
260k views

I am a noob in shell-scripting. I want to print a message and exit my script if a command fails. I've tried: my_command && (echo 'my_command failed; exit) but it does not work. It keeps ...
user459246's user avatar
  • 3,299
313 votes
12 answers
1.0m views

I want to download something with Wget using a proxy: HTTP Proxy: 127.0.0.1 Port: 8080 The proxy does not need a username and password. How can I do this?
Hakim's user avatar
  • 11.9k
313 votes
25 answers
215k views

I want to transform /foo/bar/.. to /foo Is there a bash command which does this? Edit: in my practical case, the directory does exist.
Fabien's user avatar
  • 7,119
313 votes
25 answers
801k views

I've created a script that runs every night on my Linux server that uses mysqldump to back up each of my MySQL databases to .sql files and packages them together as a compressed .tar file. The next ...
Kit Roed's user avatar
  • 5,227
311 votes
25 answers
1.6m views

I am new to Linux system and there seem to be too many Java folders. java -version gives me: java version "1.7.0_55" OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13) OpenJDK 64-Bit ...
Bosco's user avatar
  • 4,092
311 votes
14 answers
81k views

How do the Linux kernel developers test their code locally and after they have it committed? Do they use some kind of unit testing and build automation? Test plans?
Ashkan Kh. Nazary's user avatar
308 votes
6 answers
236k views

I want to check the operating system (on the computer where the script runs). I know I can use os.system('uname -o') in Linux, but it gives me a message in the console, and I want to write to a ...
kolek's user avatar
  • 4,000
308 votes
18 answers
552k views

What is the maximum number of threads that can be created by a process under Linux? How (if possible) can this value be modified?
user avatar
306 votes
8 answers
300k views

I have a problem with a Java application running under Linux. When I launch the application, using the default maximum heap size (64 MB), I see using the tops application that 240 MB of virtual ...
Mario Ortegón's user avatar
304 votes
2 answers
161k views

I’m using bash shell on Linux. I have this simple script … #!/bin/bash TEMP=`sed -n '/'"Starting deployment of"'/,/'"Failed to start context"'/p' "/usr/java/jboss/standalone/log/server.log" | tac | ...
Dave's user avatar
  • 20.1k
302 votes
12 answers
247k views

I would like to define some aliases in fish. Apparently it should be possible to define them in ~/.config/fish/functions but they don't get auto loaded when I restart the shell. Any ideas?
armandino's user avatar
  • 18.7k
301 votes
24 answers
512k views

I am trying to use grep to match lines that contain two different strings. I have tried the following but this matches lines that contain either string1 or string2 which not what I want. grep '...
hearsaxas's user avatar
  • 3,021
299 votes
3 answers
317k views

I'm running a grep to find any *.sql file that has the word select followed by the word customerName followed by the word from. This select statement can span many lines and can contain tabs and ...
Ciaran Archer's user avatar

1
3 4
5
6 7
4552