How to change the host name locally in bash [closed] - bash

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 11 years ago.
Improve this question
I want to generate ssh public key using ssh-keygen with custom host name in it at the end of the file
.
How to change the host name locally in bash.

Just provide the -C flag, the stuff at the end of the file is only a comment, not used for anything else except differentiation.
ssh-keygen -C "somecomment#somehostname"

The hostname at the end of the key file (id_rsa.pub) is just a comment. You can change is with any editor.
or if you really want to do it from the command line:
awk '{$3 = "myname#myhost.com"; print;}' id_rsa.pub > new_id_rsa.pub

Related

I have a Bash file I want to edit it and change [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
How can I change the 127.0.0.1 to another IP address using echo or cat without nano or Vim?
Here's the Bash command and the Bash file name is listpics:
python3 poc.py --cmd listPics --ip 127.0.0.1
For your specific case, you could do this:
with open('listpics', 'r+') as listpics:
data = listpics.read().replace('127.0.0.1', '192.168.1.254')
listpics.seek(0)
listpics.write(data)
listpics.truncate()

Shell script with variables [closed]

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 8 years ago.
Improve this question
I'm working a shell script to admin out email system. Essentially I get the users info and grep it to get the data I need. I've ran the below commands in terminal and they work as intended but when I use the below script I get an error "Command not found". I think its trying to run the 3rd line as a command. Anyone know what could be the problem here?
read -p "Enter email address to remove from groups: " purge_email
purge=$(python /gam/gam.py info user $purge_email)
purge_chunk=$($purge | grep -A 100 "Groups:")
echo $purge_chunk
Try:
purge_chunk=$("$purge" | grep -A 100 Groups:)
the $purge should be evaluated as formatted output the way gam kicks it out in a txt file or .csv you would use as a data source for a gam script in bash.

Bash - unzip: command not found [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 am trying to unzip the file in particular folder and i am getting a "unzip command not found" error.
I am using Cygdrive to run my bash script
#!/bin/bash
for dir in ./"$WORKING"/*
do
unzip '*'
done
The package is unzip
setup -nqP unzip
or use the GUI.
in the wild

os x terminal command [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
Does anyone know how can i remove '#2x~ipad' string from all files name in a directory
do that a file named: image#2x~ipad.png will be renamed to: image.png
I need to rename all files in a certain directory
Can I do it with a loop from terminal? any idea?
Using bash (in the terminal):
for file in *2x~ipad.png; do
mv $file ${file%%\#2x~ipad.png}.png
done

How to execute shell script in cygwin? [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 11 years ago.
Improve this question
the name.sh already save in C:\Documents and Settings\user, i type sh name.sh
sh: testing.sh: No such file or directory
any help will be appreciated!
You can just type ./name.sh and your script should run.
If your current directory is not in your $PATH, adding the ./ tells the shell to look there.
The other possibility is that you're not currently in the right directory. If the result of pwd shows you are not in C:\Documents and Settings\user, then you will need to cd to that directory, or move the script to whatever directory you are in.
Add ./ in front of the name. ./name.sh

Resources