Skip to content
Advertisement

Tag: shell

deactivate:unset:1: no such hash table element: pydoc

I am trying to setup my new laptop’s development environment. After install zsh I am constantly getting error deactivate:unset:1: no such hash table element: pydoc Please help. I have following simple aliases in my zshrc: Answer You can see virtualenv pr on github. or you can change deactivate () function. change unset -f pydoc to unset -f pydoc >/dev/null 2>&1

get available memory in gb using single bash shell command

following command returns available memory in kilobytes cat /proc/meminfo | grep MemFree | awk ‘{ print $2 }’ can some one suggest single command to get the available memory in gb? Answer Just a slight modification to your own magical incantation: P.S.: Dear OP, if you find yourself invoking grep & awk in one line you’re most likely doing it

sh file can’t work well but commands in sh can

I’m using a bash shell to export some path,like this: env.sh: after call sh env.sh,I call echo $GOPATH ,but nothing output,and I call export again to check the variables exported,but GOPATH isn’t included.But when I copy these commands in the shell file,and execute them directly in command line,it can work!why this happens?I’m using mac. Answer You need to use source

Get the PID of a process started with sudo via ssh

I need the process id of a process (here sleep 20) started remotely via SSH and sudo. date is inserted to illustrate the duration of the SSH connection. Without connection there is also no process on my remote machine, of course. On a second machine the last, complete command works fine: Any suggestion why there is this different behaviour of

Sed command in linux

How do I extract URL’s from a file? My file name is URL_name.txt This file has a lot of url inside. It looks like this: Here is my idea, I want to remove everything before URLs then I can remove everything after URL. How do I use sed command deal with it? The output should be http://www.google.com/ http://www.stackoverflow.com/ Answer You

check if a file is jpeg format using shell script

I know I can use file pic.jpg to get the file type, but how do I write an if statement to check it in a shell script? E.g. (pseudo code): Answer Try (assumes Bash v3.0+, using =~, the regex-matching operator): If you want to match file’s output more closely: This will only match if the output starts with ‘JPEG’, followed

Advertisement