shell

Remove specific words from sentences in bash?

笑着哭i 提交于 2021-02-20 19:14:12
问题 I want to remove negative words form sentence using bash script . The negative words that i meant it : [dull,boring,annoying,bad] My file text text.txt contains this sentence : These dull boring cards are part of a chaotic board game ,and bad for people I'm using this script array=( dull boring annoying bad ) for i in "${array[@]}" do cat $p | sed -e 's/\<$i\>//g' done < my_text.txt But I got the following wrong result: These boring cards are part of a chaotic board game ,and bad for people

How to join columns of two files in unix system

☆樱花仙子☆ 提交于 2021-02-20 06:20:20
问题 I have 2 files, each file has one column with multiple rows and the rows of each file are the same. How can I join the 2 files' columns together so that the final result file has two columns coming from file1 and file2? For example, file1 is: 1 2 3 and file2 is: a b c and the expected output is: 1 a 2 b 3 c 回答1: Just use the paste command. Use it like this : paste file1 file2 来源: https://stackoverflow.com/questions/12361977/how-to-join-columns-of-two-files-in-unix-system

cd .. command does not work with gcloud compute ssh while other basic commands (such as pwd) do work. Why? [duplicate]

喜欢而已 提交于 2021-02-20 04:41:11
问题 This question already has answers here : Multiple commands on remote machine using shell script (3 answers) Why would SSH commands through Putty work differently to those via PHP's phpseclib? (1 answer) Paramiko: calling “cd” command with exec_command does nothing (3 answers) Closed 2 years ago . I have a running instance my-instance running on google-cloud. I run the following code on my local machine: gcloud compute ssh my-instance --command 'pwd' gcloud compute ssh my-instance --command

cd .. command does not work with gcloud compute ssh while other basic commands (such as pwd) do work. Why? [duplicate]

别说谁变了你拦得住时间么 提交于 2021-02-20 04:41:11
问题 This question already has answers here : Multiple commands on remote machine using shell script (3 answers) Why would SSH commands through Putty work differently to those via PHP's phpseclib? (1 answer) Paramiko: calling “cd” command with exec_command does nothing (3 answers) Closed 2 years ago . I have a running instance my-instance running on google-cloud. I run the following code on my local machine: gcloud compute ssh my-instance --command 'pwd' gcloud compute ssh my-instance --command

Certain commands like IISRESET and ROBOCOPY have stopped working in Powershell v4

亡梦爱人 提交于 2021-02-20 04:35:27
问题 Certain commands like IISRESET and ROBOCOPY have stopped working in Powershell v4 I have a pretty large script that runs those 2 commands at certain points, but these now both give me the general error: iisreset : The term 'iisreset' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. These commands still work from CMD. The only changes that were made is

Connecting to server via SSH using Java - JSch and issuing shell commands

岁酱吖の 提交于 2021-02-20 03:52:01
问题 I'm trying to write a program that connects via SSH to a remote Linux server using Java. I've found a number of examples online to do this using the JSch package, but they're mostly for issuing a single command to the server right after authentication. Is there any way, however, to first authenticate with the SSH server, then, over the connection, issue commands from the user input like you would via a remote shell? 回答1: If you want to implement an interactive shell, you need to use SSH

Connecting to server via SSH using Java - JSch and issuing shell commands

倖福魔咒の 提交于 2021-02-20 03:50:46
问题 I'm trying to write a program that connects via SSH to a remote Linux server using Java. I've found a number of examples online to do this using the JSch package, but they're mostly for issuing a single command to the server right after authentication. Is there any way, however, to first authenticate with the SSH server, then, over the connection, issue commands from the user input like you would via a remote shell? 回答1: If you want to implement an interactive shell, you need to use SSH

Does zgrep unzip a file before searching? [closed]

此生再无相见时 提交于 2021-02-19 09:40:06
问题 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 3 years ago . Improve this question Does zgrep unzip a gzip file and make a temporary copy before searching or does it search directly on the compressed file? 回答1: This source of zgrep uncompresses the file with zcat and pipes the result to grep . So, no, it does not use a temporary file, but yes,

Collect output from top command using Paramiko in Python

六眼飞鱼酱① 提交于 2021-02-19 08:50:52
问题 Here I am trying to execute ssh commands and print the output. It works fine except the command top . Any lead how to collect the output from top ? import paramiko from paramiko import SSHClient, AutoAddPolicy, RSAKey output_cmd_list = ['ls','top'] ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(hostname_ip, port, username, password) for each_command in output_cmd_list: stdin, stdout, stderr = ssh.exec_command(each

Using awk to put a header in a text file

青春壹個敷衍的年華 提交于 2021-02-19 08:48:05
问题 I have lots of text files and need to put a header on each one of them depending of the data on each file. This awk command accomplishes the task: awk 'NR==1{first=$1}{sum+=$1;}END{last=$1;print NR,last,"L";}' my_text.file But this prints it on the screen and I want to put this output in the header of each of my file, and saving the modifications with the same file name. Here is what I've tried: for i in *.txt do echo Processing ${i} cat awk 'NR==1{first=$1}{sum+=$1;}END{last=$1;print NR,last