so I have the code right now down below, and I’m running into a few problems with it I’m having trouble excluding the directories being outputted by It is giving me the directories too instead of only names; I’ve tried different methods such as -prune etc. I’m having trouble with deleting the empty files The data given to me by
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
How can I check (and delete) if the last line (that contains the last occurence of a string) has a comma as last character?
I’ve been looking all over the internet but had no result. I’m trying to build a package generator (in shell/bash) and that respective package contains (one or more) json files. When browsing through a json file, if the user wants to delete one of the steps I must first take into consideration what if the step he wants to delete
how do I kill a port in use — eventmachine
I get the following error: I’m not sure what the process or port is and want to kill it so I can run my script again. How do I do that? Answer Example:
Detect wireless devices connected to Raspberry Pi in python on Linux
In my python code I need to get the list of “physical” WiFi network devices connected to Raspberry Pi I’ve been doing this by calling: and then extracting all the data I need from raw_output It works ok, but in iw help it says that Do NOT screenscrape this tool, we don’t consider its output stable. Is it really unsafe