Create a shell script with a shell script [closed] - linux

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'm creating a script which create file and insert content using
cat > /etc/file <<END
FILE CONTENT
END
It works for most files but it doesn't work when file content have shell commands in it.
I tried with the echo command but i have the same problem.
Why does it execute commands ?

The file's content includes $variables wich are expanded. To avoid variable expansion, I had to use single-quote escapes 'END'.

Related

Bash terminal error when using 'unmask' command [closed]

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 2 years ago.
Improve this question
Any time i type the 'unmask' command in my bash terminal i get the error below:
'bash: unmask: command not found'
Please, any ideas on how i can solve this problem, I believe 'unmask' is a built in command.
I am using bash --version 5.0.16(1)
Could it be that you actually meant umask?

can't edit .bashrc while it is already present in the directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 3 years ago.
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.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I'm setting up zsh in my Windows subsystem for Linux in my windows 10 machine by following some tutorial which instructs on opening my bash profile by the following command
vim~/.bashrc
but it says
bash: vim~/.bashrc: No such file or directory
I've tried using
ls -la ~/ | more
which shows the file is present, even tried copying it from the /etc/skel but still no luck
Yeah I was running the command incorrectly it required a space as suggested by #john1024 but running either of the commands
vim ~/.bashrc
and
vi ~/.bashrc
gave me a warning that the file is already open with something like a bashrc.swap file ... Eventually made my edits and saved. Thanks for the quick support. (y)
Try the below command
vi ~/.bashrc

sed search multiple strings in one file [closed]

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 4 years ago.
Improve this question
I want to search multiple strings in the same file
So far I have this working but one string only
sed -n '/XXX/,+1p' FILE > FILE
But I want
sed -n '/XXX/YYY/ZZZ/,+1p' FILE > FILE
I could not got it workin
Use \| to separate multiple patterns to match.
sed -n '/XXX\|YYY\|ZZZ/,+1p' INFILE > OUTFILE
Also, the input file has to be different from the output file (if you want to overwrite the file you should use the -i option rather than redirecting to the input file).

store a variable in linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
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.
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
Improve this question
I was trying to create variables in my bash shell which I could use whenever I wanted. More specifically, I wanted to create a variable which could store the path to a folder, example:
mypath = `pwd`
However, I can't do the following:
cd $mypath
How can I resolve this? Also, I want to store this variable so I can use after I restart my system. Do I store this in the .bashrc file?
Don't use spaces in assignment, ie
mypath=`pwd`
Furthermore, if you want your variables to be globally available you can use the export command. Example: export mypath="pwd".
If you want the variables to persist after reboot, then you do need to add it to ~/.bashrc.
You can do this with nano ~/.bashrc and adding export mypath="pwd" to the end of the file

Cygwin - setting up $PATH [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I've found it's really difficult to setup path variable. I've tried a lot of combinations but nothing works at all. My over 1h work results are but as you see on screenshot (http://puu.sh/33n0X.png )
echo $PATH
give strange directory and
rm -rf k.txt
doesn't work at all. Does anyone has idea what is wrong there? I'm totally confused about it
If you want something a little more "normal", you can suppress the current PATH being appended, and just build your own.
In your ~/.bash_profile, put something to this effect
PATH=/bin
and if you want System32 you can add it as well
PATH=/bin:${TMP%U*}windows/system32
Example

Resources