Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I would like store the terminal output to a file. I execute the command and cannot view the terminal output in the file but I am able to view the output in the terminal. Kindly help.
./bbmap.sh in=sequence.fasta covstats=constats.txt covhist=covhist.txt basecov=basecov.txt bincov=bincov.txt > output.txt
Validate the output of the script without redirecting to a file.
You can also pipe the output through tee so the output will be shown before sending it to a file.
script.sh |tee script_output.txt
Found the problem, add "command 2> file". T
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last year.
Improve this question
I am very new to Linux and Bash scripting. Also my first question on stackoverflow.
I am trying to create a bash script which I want to use from any directory.
So far this is what I did
Created a simple bash file first
#!/usr/bin/bash
echo "This is a bash script"
exit 0
I set the permissions for execute using chmod +x myfilename.sh
And then I edited the .profile file under ~/.profile
Added the line "export PATH="$PATH:$HOME/bash_course/scripts"
After that I ran the command source ~/.profile
Now I tried to run myfilename from the terminal, but it returns Command not found.
Any idea what could have gone wrong?
I checked the path of my bash and it is /usr/bin/bash
If I run ./myfilename.sh from file path, it is working. But I am trying to run from other directories.
FYI : I am doing all of this on a WSL
Found the issue. My path was actually /bash-course/scripts and not /bash_course/scripts
I corrected the exported path under .profile
Thanks everyone
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
I am working on some kind of version control for a specific software (Bash script.)
When a new version releases, the code should be updated to the latest release, I have figured this out but I seem stuck and can't make the replacement inline.
#First we download the source code with wget, it returns a text with the new code
wget www.example.com/sourcecode | cat . > $0
How can I redirect that output (text / script) to the current script who's executing it and replace it.
Note $0 gives us the location of the current script. So the cat command, just should replace the new text coming from wget to the current script.
Thanks!
Your question is a bit confused, so I can try to guess your needs.
Are you asking how to capture the output of the commmand you posted?
If yes, the solution is:
source_file_content=$(wget -O - http://www.example.com/sourcecode)
# Do anything with ${source_file_content}
Let me know if it is right for you.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
what does this command do?
!/bin/bash
My first script
clear
echo (I don't know what will come after echo , can you help me with that too?)
./hello.shell
#!/bin/bash is called the shebang (you missed the leading #).
It tells which program will execute your script.
clear is for clearing screen.
echo outputs following argument to the standard output (your terminal by default). But you must not surround your string with parenthesis as it's used for grouping command in a sub-shell. If you want to print (...), you'll have too use double quotes :
echo "(I don't know what will come after echo , can you help me with that too?)"
./hello.shell will execute your script after you gave it execute permissions with chmod +x hello.shell.
Note that commonly used extension for a shell script is .sh rather than .shell.
For more, try theses links :
http://mywiki.wooledge.org/BashGuide/
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/
#!/bin/bash tells to the SO that this file is a script and that bash is the shell that must execute it. So you can found: #!/opt/bin/perl for perl scripts, #!/bin/csh for c-shell, #!/bin/zsh ...
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I want to run multiple background processes through ssh, aggregate all outputs and errors to the same file and redirect the logs to papertrail using remote_syslog
Following this answer i execute a ruby script in background like this :
ssh deploy#xx.xx.xxx.xx 'cd path/to/my_app; nohup ruby my_script.rb > log/script.log 2> log/script.log < /dev/null &'
It works as long as i only run one script. If i run multiple scripts i only see the output of the first script in the log file.
Can you explain what i'm doing wrong ? Or provide a better way to achieve this. Thanks !
(the log file is in path/to/my_app/log/script.log)
Solution :
Thanks to devnull comment i solved it, it was so simple... The proper command is :
ssh deploy#xx.xx.xxx.xx 'cd path/to/my_app; nohup ruby my_script.rb >> log/script.log 2>> log/script.log < /dev/null &'
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm trying to write a script to run one of my .jar files as daemons, but I am not understanding how to create a .sh extension file in Ubuntu. I have already used vi to create a file with the code that I want, but I cannot figure out how to define the file to specifically be a .sh file. For example, I want to convert my file "foo" or "foo.txt" into "foo.sh".
Is there a simple command I am not seeing that can convert files to a .sh extension or is it a more complicated process?
Use this as a template:
#!/bin/bash
# content of your script
The first line is called a shebang and tells the OS what program that should be used executing the content of the file, in this case, bash.
To make the file executable:
chmod 755 foo.sh
To execute your script do:
./foo.sh