terminal

Why does printf( “%c”, 1) return smiley face instead of coded char for 1

霸气de小男生 提交于 2019-12-23 09:34:03
问题 This is my code #include <stdio.h> int x,y; int main( void ) { for ( x = 0; x < 10; x++, printf( "\n" ) ) for ( y = 0; y < 10; y++ ) printf( "%c", 1 ); return 0; } It returns smiley faces. I searched everywhere for a code for smiley face or a code for 1 but I didn't manage to find any links whatsoever or any explanation why char value for 1 returns smiley face, when the ascii code for 1 is SOH. I researched answers for this question but I didn't find any answers that explain why this happens.

What is the equivalent to “which” for commands that don't refer to executables?

偶尔善良 提交于 2019-12-23 09:15:35
问题 I'm trying to find out how a specific command is defined. I've checked all locations of $PATH and could not find any file that is named like my command, so it seems to be something else. Here is an example using nvm, that is not an executable: me@MacBook:~$ which cat /bin/cat me@MacBook:~$ which nvm me@MacBook:~$ nvm --version 0.33.8 which nvm simply returns nothing. What is the equivalent of "which" for commands like this in unix based systems? 回答1: The command you are looking for is type .

Can't open sublime text in tmux after upgrading to Yosemite

妖精的绣舞 提交于 2019-12-23 09:09:47
问题 On my Mac OS Yosemite, I can open a terminal and run subl and it opens Sublime Text. But, if I start a tmux session and run subl , I get the error: Unable to launch Sublime Text If I try: open -a "Sublime Text" I get the error: LSOpenURLsWithRole() failed for the application /Applications/Sublime Text.app with error -10810. 回答1: I found an answer for the same problem over in superuser. Unfortunately, there doesn't seem to be a solution to the problem at the moment. The link to the answer is

Xcode App No Longer Reads Input From the Folder The App is Stored In

99封情书 提交于 2019-12-23 09:05:44
问题 The title is a bit long-winded, but basically, I've written an app that reads and writes its input and output to text files. The entire time, it would read and write the files directly in the same directory as my Xcode derived data->project->build->products->debug folder. This was where everything was being written to and read from. I don't have a custom path set up for the application, so it just saves wherever the app is located. For the first time ever, I ran Apple's Instruments app, to

Reset bash history search position

亡梦爱人 提交于 2019-12-23 08:45:23
问题 In a terminal the Bash history can be searched easily with Ctrl + r . But what if I cannot find what I am looking for? I am stuck in the middle of my history. What if a want to search again from the beginning? Is there another shortcut to reset the history search? 回答1: There is Meta + > , which is bound to end-of-history and useful if you're in the middle of your history. The meta key is usually the Alt key. If you see that your incremental history search isn't successful, you can use Ctrl +

Bash regex matching not working [duplicate]

。_饼干妹妹 提交于 2019-12-23 07:29:24
问题 This question already has answers here : Bash Regular Expression — Can't seem to match any of \s \S \d \D \w \W etc (5 answers) Closed last year . so I have this function function test(){ local output="CMD[hahahhaa]" if [[ "$output" =~ "/CMD\[.*?\]/" ]]; then echo "LOOL" else echo "$output" fi; } however executing test in command line would output $output instead of "LOOL" despite the fact that the pattern should be matching $output... what did I do wrong? 回答1: Don't use quotes "" if [[ "

Mac OS X /usr/bin/time verbose flag

早过忘川 提交于 2019-12-23 07:29:14
问题 I have been trying to run the usr/bin/time command in my terminal (Bash) with the verbose flag --verbose or -v but have repeatedly been getting this error: /usr/bin/time: illegal option -- v usage: time [-lp] command. The command I have been running looks like basically like this: /usr/bin/time -v python practice.py Any ideas how to get this to work properly on a Mac? (I have OS X Yosemite)? 回答1: If you have homebrew, you can get GNU time by installing the gnu-time package: brew install gnu

sudo command not found on Cygwin

左心房为你撑大大i 提交于 2019-12-23 06:48:21
问题 I am currently trying to install and update a few packages on a Windows OS. The only matter is that I am using Cygwin in order to type the commands through a terminal (as I'm aware, I can type in Linux type commands such as cd, ls etc. on Cygwin - I may be wrong). However, when I try to install a package like: sudo apt-get install paparazzi-dev I get the reply: -sh: sudo: command not found. Does anyone have an idea as to how I can fix this problem? 回答1: Cygwin is not a full Linux distribution

What happens when I sudo bash -c? [closed]

狂风中的少年 提交于 2019-12-23 06:29:51
问题 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 3 years ago . I know that sudo bash -c 'some_command' will run some_command with the same privileges as sudo. I'm confused as to what's happening? Does it run some_command in bash as sudo (same as sudo bash ) then switch back to my current user? Why am I not left in an instance of bash with sudo privileges like I would when I

What happens when I sudo bash -c? [closed]

寵の児 提交于 2019-12-23 06:28:07
问题 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 3 years ago . I know that sudo bash -c 'some_command' will run some_command with the same privileges as sudo. I'm confused as to what's happening? Does it run some_command in bash as sudo (same as sudo bash ) then switch back to my current user? Why am I not left in an instance of bash with sudo privileges like I would when I