unix

gcc generates unnecessary (?) instructions

陌路散爱 提交于 2020-08-15 10:38:06
问题 I decided to compile a very basic C program and take a look at the generated code with objdump -d . int main(int argc, char *argv[]) { exit(0); } After compiling it with gcc test.c -s -o test.o and then disassembling with objdump -d my text segment looked like this: Disassembly of section .text: 0000000000001050 <.text>: 1050: 31 ed xor %ebp,%ebp 1052: 49 89 d1 mov %rdx,%r9 1055: 5e pop %rsi 1056: 48 89 e2 mov %rsp,%rdx 1059: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp 105d: 50 push %rax 105e:

Unix ls command option to print file author

寵の児 提交于 2020-08-12 03:59:06
问题 Can anyone tell me which ls option to use to print the author or owner of a file? I have searched for over 2 hours and the only thing I have found is hyphen hyphen author which doesn’t work. I tried Unix.com, unixtutorial.com, Ubuntu.com and about a dozen other sites. I used Google, Yahoo, Bing, DuckDuckGo. I’m about ready to chuck it all and give up. 回答1: To get the author, you combine --author with -l (it doesn't work without it). Keep in mind that, in most UNIXes that support ls --author ,

create perl script to connect remotely to another server and read File?

▼魔方 西西 提交于 2020-08-08 07:00:27
问题 I am new to perl programming also to networking . My Task is to connect to remote server and read file from server using Perl script.I know how to read file from local machine but not how to read from remote server? Code to read file from local machine but not know how to connect to remote server and read file? #!/usr/bin/perl use 5.010; use strict; use warnings; open(FH, 'C:\Users\saqib riaz\Desktop\saqi\properties.txt'); while(<FH>) { "$_"; } close(FH); I am using window operating system

Duplicate, but still use stdout

强颜欢笑 提交于 2020-08-07 06:26:08
问题 Is there some magic I can do with dup2 (or fcntl ), so that I redirect stdout to a file (i.e., anything written to descriptor 1 would go to a file), but then if I used some other mechanism, it would go to the terminal output? So loosely: int original_stdout; // some magic to save the original stdout int fd; open(fd, ...); dup2(fd, 1); write(1, ...); // goes to the file open on fd write(original_stdout, ...); // still goes to the terminal 回答1: A simple call to dup will perform the saving. Here

How to concatenate huge number of files

痴心易碎 提交于 2020-08-02 07:11:23
问题 I would like to concatenate my files. I use cat *txt > newFile But I have almost 500000 files and it complains that the argument list is too long. Is there an efficient and fast way of merging half a million files? Thanks 回答1: If your directory structure is shallow (there are no subdirectories) then you can simply do: find . -type f -exec cat {} \; > newFile If you have subdirectories, you can limit the find to the top level, or you might consider putting some of the files in the sub

Find the depth of the current path

∥☆過路亽.° 提交于 2020-08-02 05:23:50
问题 How can I write a shell script to find the depth of the current path? Assuming I am in: /home/user/test/test1/test2/test3 It should return 6. 回答1: A simple approach in fish: count (string split / $PWD) 回答2: With shell parameter expansions, no external commands: $ var=${PWD//[!\/]} $ echo ${#var} 6 The first expansion removes all characters that are not / ; the second one prints the length of var . Explanations with details for support by POSIX shell or Bash (the links in parentheses go to the

Supervisorctl error: unix:///var/run/supervisord.sock refused connection? [closed]

僤鯓⒐⒋嵵緔 提交于 2020-08-01 06:15:47
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 12 months ago . Improve this question This is my config flie.I run supervisord -c /etc/supervisor/supervisord.conf it works well. When I try to run supervisorctl -c /etc/supervisor/supervisord.conf ,the error happened: Error: , Unknown protocol for serverurl /var/run/supervisord.sock: file: /usr

Supervisorctl error: unix:///var/run/supervisord.sock refused connection? [closed]

99封情书 提交于 2020-08-01 06:15:29
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 12 months ago . Improve this question This is my config flie.I run supervisord -c /etc/supervisor/supervisord.conf it works well. When I try to run supervisorctl -c /etc/supervisor/supervisord.conf ,the error happened: Error: , Unknown protocol for serverurl /var/run/supervisord.sock: file: /usr

Needs to execute one sql query against two Oracle DBs in shell script at a time and export the data to separate csv files

為{幸葍}努か 提交于 2020-07-31 04:19:03
问题 I have file1.sh file and which internally needs to execute one sql query against two Oracle DBs at a same time and needs to export date to csv fiiles, below is the sample shellscript which executes the query against two dbs. .... #!bin/bash set -X sqlplus -S ${user1}@${DBCONNECTIONNAME_1}/${Pwd} Datesquery.sql & >> ${Targetdirectory}/csvfile1.csv sqlplus -S ${user1}@${DBCONNECTIONNAME_2}/${Pwd} Datesquery.sql & >> ${Targetdirectory}/csvfile2.csv sed 1d csvfile2.csv > file2noheader.csv cat

Split string on a backslash (“\”) delimiter in awk?

萝らか妹 提交于 2020-07-30 00:55:53
问题 I am trying to split the string in a file based on some delimiter.But I am not able to achieve it correctly... Here is my code below. awk 'var=split($2,arr,'\'); {print $var}' file1.dat Here is my sample data guys. Col1 Col2 abc 123\abc abcd 123\abcd Desire output: Col1 Col2 abc abc abcd abcd 回答1: Sample data and output is my best guess at your requirement echo '1:2\\a\\b:3' | awk -F: '{ n=split($2,arr,"\\") # print "#dbg:n=" n var=arr[3] print var }' output b Recall that split returns the