The shell is unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …).

learn more… | top users | synonyms (1)

0
votes
0answers
3 views

Using expect script to pull files non-inteactively

I am trying to connect to a remote host by SEFT and pull fies. I have create an 'expect' script to provide the password automatically. I have succeeded in getting the sftp> prompt. However I am unable ...
0
votes
0answers
9 views

useradd failing

Debian 8, I'm trying to allow a user to run Wireshark. user1@system:~$ sudo useradd -G wireshark user11 useradd: user 'user11' already exists However: user11@system:~$ groups user11 cdrom floppy ...
-1
votes
0answers
16 views

Running a .sh within a .sh script

I've been banging my head against the wall for two days trying to get this script functioning. I'm rather new to linux so I'm hoping it might be something simple. I'm using a Windows 10 machine and ...
0
votes
0answers
19 views

How do you create 10 users but with no password using shell script? [on hold]

How do you create 10 users but with no password using shell script? Also, how do you then assign the users into separate 4 groups? Thank you.
3
votes
3answers
47 views

How to make two commands consume input from stdin sequentially?

The following perl script consume-10-lines-and-exit reads ten lines from stdin and prints them. After that it exits. #!/usr/bin/env perl use strict; use warnings FATAL => 'all'; for (my $i = 0; ...
1
vote
1answer
30 views

How to organize files in Linux/Unix shell?

I would like to try to organize my documents, and I was told that I can do this using the linux/unix cygwin terminal. I searched for the command in google but all I ever did find was organizing the ...
-2
votes
0answers
25 views

how i can Download with wget? [on hold]

am trying to Download all of the files in website and every link inside it , with sudo wget -m https://someurl.com i need when it gets to the other link create a directory for it before ...
3
votes
1answer
31 views

Combining every two column values in file

I have a file with (with only one line) with multiple columns say 4 (in this case) : A B C D And I want the output as every possible combination of column values taking 2 at a time like: AB AC AD ...
1
vote
1answer
26 views

Remove certain types of files except in a folder

I have a command in my makefile for clean: rm -rf */*.o */*.cmo */*.cmi */*.cmx */*.cma */*.cmxa */*.annot Now I would like to write a cleanpartial that removes these files except those in the ...
3
votes
1answer
47 views

execute command from find called by find

Is there a way to call find recursively? I would like to search for files matching a given pattern only in directories matching another pattern. Basically: for each (sub)directory D matching ...
1
vote
2answers
43 views

Define a variable to awk pattern matching from bash

I am trying to grab 100 lines after the text "time: X" with X in {0,40,80,...,200}. Here is what I have so far: #!/bin/bash start=1 end=5 for i in $(seq $start $end);do j=$(($i*40)) awk '/time: ...
1
vote
0answers
14 views

Passing external parameter to .exe on Windows using winexe from Linux

I am trying to execute a .exe on Windows from Linux using winexe. This exe requires an external parameter (string) to be fed alongwith. With the following command I have succeeded in initialising the ...
1
vote
1answer
29 views

code to display the text TRUE

I'm a complete newbie and I'm starting to learn the basic for shell scripts. So I apologize if this question is very simple for most users. I'm trying to display the text TRUE to the screen if a file ...
2
votes
0answers
36 views

Prevent scp and less commands reading interactive tcsh script

I'm using tsch through PuTTY, and let's start by this: please don't try to convince me to migrate to another shell...:) It's being a long time that commands like scp and less didn't work well for me. ...
0
votes
0answers
15 views

vim + tmux: some shortcuts broken?

When I am using vim inside of tmux, some of my shortcuts are broken. E.g. I have bound Ctrl + up/down and Shift + up/down in my .vimrc and when I'm running vim inside of tmux these shortcuts do not ...
3
votes
2answers
78 views

Filter files generated by `find` by parsed output of `file` command

I'm writing a quick tool to inspect the contents of a node.js node_modules folder or python virtualenv for native dependencies. As a quick first approximation to this I wrote the following command. ...
0
votes
2answers
33 views

Flow control using Unix shell

I need to do an exercise at the university, its all about reading 3 values and identify if there is any duplicated value, which value is the greatest and which one is the least, the idea is if you ...
0
votes
0answers
17 views

Create a rpm package [on hold]

How can I make a rpm package to create it for my script?. Scenario: I have an script (many of them) and I want to be able rpm way and not using the sh such as the main application executable. I ...
0
votes
1answer
30 views

How to insert a string before a matched string

How can I insert a string before a matched string. Suppose I want to insert a string a before "if (PROTOCOL == "https://")" string. Please tell me how can I do this?? or How to search and replace ...
0
votes
2answers
29 views

Compare and return first instance of n characters from a list

Lets say I have the output of this command saved to a file. cat /dev/urandom | tr -dc '[:graph:]' | fold -w 1000 | perl -pe 's/(.)(?=.*?\1)//g' | head -n 50 I would like to compare only the first n ...
0
votes
1answer
24 views

Please verify the result which i get using grep for korn shell

when i run the command ps -ef | grep ksh on my server i get the result as - /bin/ksh ./abc.ksh ./xyz.ksh where abc and xyz are my shell scripts. what does this symbolize ? Is one script calling ...
2
votes
3answers
37 views

All files in a directory that do not end in a specific string?

I want to find all text files in a directory that do not end with the string: hello world How can I do this?
1
vote
1answer
30 views

Creating if/than statement to move files to another location based on value of 1 column?

I have thousands of xyz (latitude,longitude,elevation) text files that I want to separate by latitude or longitude. How and what commands could I use to create an "if latitude(column1) is greater than ...
0
votes
0answers
20 views

Is there a way to get partition information of a disk with sysfs?

my first question here - so please, don't be too hard with me... As the title says: I am wondering if there is a way to get partition information of a disk with sysfs. I know about some different ...
0
votes
1answer
30 views

how to input a file as a variable in a shell script

I need to input the path of a file in shell script as a variable and use the file in the same script.Suppose the path is /home/pi/dest/file and i want to use the file as a variable.Can anyone tell me ...
0
votes
0answers
21 views

Emptying a log file getting updated with 2>&1 output redirection [duplicate]

I have a server which constantly writes outputs and errors to stdout and stderr. The command line I use for running my server is: Server options-list > log.txt 2>&1 & Now the problem ...
0
votes
1answer
30 views

Printing Space Between Strings

#!/bin/bash ARRAY="185.18.207.66 31.18.212.113" result="" for i in $ARRAY do result=$(printf '%s %s' "$result" "$i" "checked") done paste <(printf "%s\n" $result) I am trying to print ...
0
votes
1answer
24 views

Shell script getting 'permission denied' despite using umask 000 before command

I have a shell script (build.sh) that ends by attempting to copy some files into a new directory. However it says: mkdir: cannot create directory ...
1
vote
1answer
19 views

variable doesn't change after find & while [duplicate]

My code var=34 find $1 -type f | while read line; do file_status=`file "$line"` file_name=`echo $line | sed s/".*\/"//g` line_length=${#file_name} if [ $line_length ...
1
vote
2answers
81 views

Escaping in bash

Given a text message, I need to programmatically generate a bash command to open terminal emulator and show this text in it. For example, for HelloWorld input string I need to return the following ...
0
votes
0answers
26 views

How to convert the timestamp to readable date format [duplicate]

$timestamp="160402074632" Dates=$timestamp +"%Y-%M-%D" I want this to be converted to a readable date format like “Thu Dec 9 12:50:32 CET” and store it in Dates variable if i give echo $Dates , i am ...
7
votes
2answers
395 views

Wait for stdout stream to finish and then add its contents to a file

I am trying to run a command in bash where I have a command 1 which accepts a large amount content through stdin and then outputs that content to a file.txt, however, command 1 generates a stream of ...
9
votes
2answers
241 views

What are the security issues and race conditions in using `find -exec`?

From the find man page: -exec command ; There are unavoidable security problems surrounding use of the -exec action; you should use the -execdir option instead. -execdir command {} + ...
0
votes
2answers
39 views

Extracting a certain folder from a tarball - how do I tell it where to put the file once extracted?

I've looked around at multiple sources for this question and I know how to extract the file, but neither source told me how to state where to put the folder once it has been extracted. I tried this: ...
0
votes
1answer
18 views

Excluding files whilst using tar to zip site contents not working [closed]

I'm trying to zip the contents of a site using tar and exclude a bunch of folders and error_log files but it doesn't seem to be working, when it's processing I still see many of the excluded files ...
-1
votes
1answer
51 views

Organize a file [closed]

I want to thank the great help and support. Well, I have the following file: name id alello chr pos snp s1 215 a 1 11 a215 s1 216 a 1 11 a216 s1 217 ...
1
vote
4answers
54 views

How do I echo a string with multiple spaces in bash “untouched”? [duplicate]

I assigned a var like this: MYCUSTOMTAB=' ' But using it in echo both: echo $MYCUSTOMTAB"blah blah" or echo -e $MYCUSTOMTAB"blah blah" just return a single space and the rest of the ...
3
votes
4answers
69 views

How can I save the output of “echo -e '\e]4;40;?\a'” into a variable, or pipe it?

Inspired by this forum post, I ran this command at a Bash prompt: echo -e '\e]4;40;?\a' Which outputs: # 4;rgb:8b8b/cdcd/0000 But the weird thing is, the output somehow becomes my prompt's next ...
0
votes
5answers
102 views

How do I display all the characters between two specific strings?

I want to display all the characters in a file between strings "xxx" and "yyy" (the quotes are not part of the delimiters). How can I do that ? For example, if i have input "Hello world xxx this is a ...
24
votes
2answers
1k views

Opening Your Command Prompt In A Text Editor - What Is This Called?

One of my favorite tricks in Bash is when I open my command prompt in a text editor. I do this (in vi mode) by pressing ESC v. When I do this, whatever is in my command prompt is now displayed in my ...
1
vote
1answer
34 views

Interactive remove files listed with paths in text file

I am trying to interactively remove files listed with their paths in a text file. The command I am trying is: xargs rm -i <filelist.txt The error I get is: rm cannot remove ...
1
vote
0answers
35 views

Add bash to base Linux Kernel?

We have a proprietary SBC (Single Board Computer) type of platform that is a large sized scale Raspberry Pi essentially. It is ARM based and uses Linux Kernel v3.# as its base. This isn't an Ubuntu ...
1
vote
3answers
29 views

Remove front-slash using sed

I have a text file that contains following https://git.centos.org/git/rpms/abc.git https://git.centos.org/git/rpms/abc.git/ https://git.centos.org/git/rpms/abc When I run the following command, ...
0
votes
1answer
33 views

sed cannot insert if a file ends with empty line

I have a file uca.xml (Thunar configuration for custom actions): <?xml encoding="UTF-8" version="1.0"?> <actions> <action> <!--some code--> </action> ...
0
votes
2answers
33 views

How to handle space character in input from user

I have recently started working with Shell scripting. So, I am facing one issue that when i am taking filename as an input from user, then if I give spaces then it does not get handled with my code. ...
-2
votes
0answers
14 views

Will zip -r command on remote server be cancelled if I exit terminal? [duplicate]

I have done a lot of Googling, and cannot find an answer. I have made a "zip -r home" request on my server via my terminal. The home directory is over 30GB. I need to leave the office at some point ...
-1
votes
2answers
20 views

collect and create tab separated matrix

I have 6 text files (each corresponds to a specific sample) and each file looks like this: Gene_ID Gene_Name Strand Start End Length Coverage FPKM TPM ENSMUSG00000102735 Gm7369 + ...
0
votes
1answer
37 views

syntax error: invalid arithmetic operator (error token is “.c”)

I am trying to test if file "file1.c" is present in the current working directory, what am I doing wrong with my test command? I thought I understood this command, am I doing something wrong for the ...
3
votes
4answers
65 views

How to execute multiple commands remotely on few servers?

I am trying to automate these steps so that I don't need to do this on every machines manually. I need to install latest app server software (abc.tar.gz) on all the unix boxes. I need to do this in ...
4
votes
1answer
55 views

Automatically open text files in editor instead of attempting to run them?

When I accidentally type the name of a text file without some kind of editor command, and the text file is not a shell script, I get a "permission denied" error*, since the file is not executable, and ...