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, …).
0
votes
2answers
19 views
Does cp -a refresh existing files, overwrite or skip
If I use cp in archive mode e.g
cp -a /my_old_directory/* /new_location/my_new_directory/
to replicate a directory structure and all that is in it.
If I then run the same command again will any ...
-1
votes
3answers
30 views
How to swap two words with sed and with multiple delimiters?
Just letters are accepted in words, any other characters are delimiters.
I want to exchange the first word with the third word.
sed -E 's/([A-Za-z]+) [^A-Za-z] ([A-Za-z]+) [^A-Za-z] ([A-Za-z]+)/\3 \2 ...
0
votes
1answer
25 views
I moved a new program into my bin folder, but nothing happens when I try to run it [on hold]
I have two identical files in my ~/bin folder, test and test2. Both just print a string. One works; the other, which I just put in there today, doesn't. In fact nothing happens at all, which is odd. ...
0
votes
1answer
30 views
Setting up aliases with interactive ssh session [duplicate]
I need to keep ssh'ing into many-different Linux boxes (Ubuntu mostly) and every time I miss my basic aliases. Is there a way to setup aliases etc
while opening an interactive ssh a machine
without ...
-1
votes
0answers
13 views
Restricted Shell Access, For AD users, Using VAS to allow users [on hold]
I have to restrict AD users using groups as well as restrict the commands they can execute. I have RHEL server with Dell VAStool for authenticating users.
How can I setup a restricted shell for AD ...
0
votes
0answers
25 views
Testing Remote SMTP Server Port
I am currently working in a lab environment to test a script for my production environment.
My environment has several remote firewalls, all of which have an external mail Virtual IP (VIP). Our ...
0
votes
1answer
36 views
Why does 'find -mtime +1' include today's files when used in a script? [on hold]
I'm using the following find command in a script:
find . -type f -mtime +1
When I use it from an interactive shell, this gives only old files, but in the script it also gives today's files. Why? ...
0
votes
2answers
35 views
How is redirection implemented?
Is redirection a concept of the shell, not of the OS kernel?
How is redirection implemented in terms of system calls?
Is redirection implemented similarly to pipe?
0
votes
0answers
15 views
shell connection mysql connection appears to be blocked
See mysql master-slave synchronization status.
I error occurs in connection with the following shell mysql:
$(mysql -h${Mysql_Server} -u${Mysql_Slave_user} -p${Mysql_Slave_passwd} -e 'show slave ...
0
votes
2answers
32 views
Unable to execute bash script inside expect script
i have a expect script like
#!/usr/bin/expect
.....
spawn passwd
expect "password:"
send "password"
....
....
....
~/test.sh
Wile executing this, I'm unable to run bash script test.sh.
How to ...
0
votes
0answers
16 views
Using expect script to pull files non-interactively [on hold]
I am trying to connect to a remote host by SEFT and pull files. I have create an 'expect' script to provide the password automatically. I have succeeded in getting the sftp> prompt. However I am ...
0
votes
0answers
15 views
useradd failing [duplicate]
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
34 views
Running a .sh within a .sh script [on hold]
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
26 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
49 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
31 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 ...
-3
votes
0answers
29 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
27 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
48 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
45 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
15 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
34 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
37 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
16 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
79 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
36 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
19 views
Create a rpm package [closed]
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
31 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
25 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 ...
3
votes
3answers
48 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
22 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
82 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 ...
8
votes
2answers
400 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 ...
10
votes
2answers
252 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
57 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
70 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
108 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 ...