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
20 views

Why rsyslog leaves the last file in spool directory

Suppose I am using a rsyslog remote server (R1) & have a client box (C1). C1 is configured to sync up and use R1 for logging (over port 514; TCP) The spool directory is '/var/log/rsyslog'. Now, ...
1
vote
2answers
24 views

How can I properly escape a string to be passed to a shell with a command argument [duplicate]

How can I properly escape arbitrary commands? For example: sudo -u chris sh -c 'echo "\"leftright\""' The above echos: "leftright" How would I echo out: "left'right" I've tried the ...
2
votes
1answer
94 views

Finding out what sh is [duplicate]

I am writing a set of scripts that I want to be portable, but I need to know whether sh on the current platform stands for bash, ksh, or ash. Is there a clear way to do it? What comes to my mind ...
0
votes
0answers
17 views

What does a hash key preceded by an exclamation key (!#)mean? [migrated]

See the following script from scala tutorial, What does the !# mean? #!/bin/sh exec scala "$0" "$@" !# object HelloWorld extends App { println("Hello, world!") } HelloWorld.main(args)
3
votes
4answers
168 views

Comparing each file in two directories and copying it to one if it differs from it's counterpart

How can I compare all files in two directories and copy the ones that are different to one of the directory. For example, say we have dir1 and dir2: dir1: build.gradle gradle.properties ...
0
votes
2answers
68 views

Shell Script: Sending input to background process

I am using the following script to watch a folder, and if the size changes and a file doesn't exist, it runs a script. #!/usr/bin/sh SCRIPT="dim_import/xdir" while true; do size=$(du -s ...
2
votes
2answers
69 views

How can I setup a separate bash environment with only GNU utilities on OS X?

For the last 5 years, I have used linux as my everyday OS for performing scientific computing. My work recently gave me a Mac that I will be the primary user for the next few months. I keep running ...
4
votes
2answers
76 views

Is it possible to escape quotes within escape quotes within escape quotes within escape quotes?

I'm guessing someone will tell me I'm doing something wrong and dumb and noobish, but I'm trying to script something in the most straightforward method possible and use sudo commands to do something ...
-2
votes
3answers
42 views

Execute the shell script option by option

I have 3 options create a directory,if exist rename it. copy a directory,if exist in target directory rename it. exit 0 these are the options. in execution time to display this options and there ...
2
votes
3answers
58 views

reverse cat files order

I need to do log analysis and I am facing problem that cat access.log* display latest log file first. I tried to sort logs which takes a lot of time because I have logs from couple of years back. And ...
0
votes
1answer
14 views

Bash overwrites the first line when using custom PS1 prompt [duplicate]

My question is similar, but different to, this question. I have created a custom PS1 in my .bashrc, as follows: STARTCOLOR='\e[0;36m'; ENDCOLOR="\e[0m" export PS1="\n$STARTCOLOR\u@\h:\! <\t> ...
2
votes
1answer
54 views

combine two files to single file with combined columns

I am new to linux/unix shell scripting and struggling to combine two files into a single file with all columns from both files. I am providing my example files. File 1 chr loc T1 C1 chr1 100 2 ...
2
votes
2answers
134 views

How to pass shell variable to an awk search pattern?

In my bash script I have a variable that I am trying to pass to a pattern to search for using awk. However what I expected to happen is not working. I have the following text file (text.txt): ...
0
votes
1answer
43 views

Numeric test in bash: integer expression expected

I created a simple script in bash language to do cleaning of the recycle bin in Ubuntu. here is the script "recycle.sh" #!/bin/bash PUBLIC_PATH="/home/fileserv/.recycle/Public" ##### Clean public ...
0
votes
3answers
58 views

Delete all files that DON'T have duplicate names?

Given a large list of files, containing the following: FILE1.doc FILE1.pdf FILE2.doc FILE3.doc FILE3.pdf FILE4.doc Is there a terminal command that would allow me to remove all files that do not ...
1
vote
3answers
69 views

Shebang does not set SHELL in cron

I have a script containing: #!/bin/bash printenv When I run it from the command line: env testscript.sh bash testscript.sh sh testscript.sh every time, it outputs SHELL=/bin/bash. However, when ...
1
vote
1answer
22 views

Can I do a delay delivery in Thunderbird or Evolution

Now we have an option of "Delay Delivery" in Outlook. Can we do something like that in thunderbird/evolution or any other linux client ?
0
votes
0answers
30 views

what is scriptname TODAY 0 mean in crontab?

We have some scripts scheduled in crontab with TODAY 0 or YESTERDAY 0 after the script name. What does they mean?
2
votes
1answer
28 views

Secure share in samba not working, why?

The secure share that I created in samba with a password doesn't seem to work. I have the following on my /etc/samba/smb.conf on a Linux Mint box(3.13.0-37-generic) box. [myshare] ...
2
votes
3answers
42 views

How to make an alias permanent?

I have created an alias: alias shh='sqlplus hfdora/hfdora@hfd1" After creating this alias I was able to enter my database only by typing shh. But after closing my shell, I wasn't able to find ...
3
votes
1answer
37 views

Store specific output to a shell variable

I am looking to store the output of the svn info command, more precisely the revision number into a variable for further processing. I just need the 4 stored. Can anyone help me please? $ svn info ...
0
votes
1answer
11 views

ssh-copy-id doesn't copy to non-default location

Does ssh-copy-id recognize if the authorized_keys file is not in ~/.ssh? I am storing my authorized keys file in a different folder, which I have configured as: AuthorizedKeysFile ...
1
vote
1answer
35 views

How to parse a CSV file based with groups made of specific number of rows?

I have a CSV file which has the following format: Date,Towns,Count1,Count2 6/26/2015,HYDERABAD,234552,0 ,KARIM NAGAR,7520,0 ,RAJAMUNDRY,7248,256 ,KURNOOL,5848,32,0 ...
2
votes
4answers
68 views

What's the name of the environment(?) variable with current terminal width?

I know this is something simple, but I can't recall where it's located/named. Where's the variable for the current width of the terminal stored? I see this answer talks about changing things: How ...
-6
votes
1answer
27 views

shell programing error [closed]

With the following shell script, why I am getting errors syntax error near unexpected token `)' Shell Script 2) echo "enter file for rename"; read f1; echo "enter newfilename"; read f2; mv $f1 ...
1
vote
1answer
59 views

Listing directories and understanding ls

On ls man page, I saw this -d, --directory list directory entries instead of contents, and do not dereference symbolic links on my current folder: drwxr-xr-x 2 oracle oinstall 4.0K Jul ...
1
vote
2answers
62 views

“Argument list too long” in for loop

My shell script look like this: #!/bin/bash for file in *.fasta do signalp $file > $file.txt done In the working folder I have 18.000 .fasta files. I want to run each through the signalp ...
0
votes
1answer
42 views

ln -s removes part of a a file name, filename passed as a var

I use a script to link some of the files I download to a different directory. When there are "-" in the file name, ln - s wont read the path correctly, even though the variable will be logged ...
5
votes
3answers
206 views

How to forward between processes with named pipes?

The /tmp/in, /tmp/out and /tmp/err are named pipes, already created and opened by some process (for reading, writing and writing, respectively). I would like to create a new process that pipes its ...
2
votes
3answers
64 views

How can I copy three partitions of my disk with a specific beginning and ending using dd?

Using the fdisk -l command I got the following answer: Device Boot Start End Blocks Id System /dev/sda1 * 2048 28266495 14132224 27 Hidden NTFS WinRE ...
4
votes
1answer
84 views

How does the “subl” command work?

To open a file to edit in gedit I run gedit sample.py &. But with Sublime Text it is simply subl sample.py. This opens the file to edit and it doesn't run in the background (in my shell). How ...
1
vote
1answer
23 views

Installed PDFInfo with Homebrew Cask but no command associated with “pdfinfo”

First, please excuse this very basic question. I'm sorry I have to ask it, but it's very difficult to find your way around the shell at the beginning. I installed pdfinfo with Homebrew Cask: brew ...
0
votes
4answers
59 views

Copying Only Directories With Files

I am trying to copy files and the directory it is in to another location. I can find the path like this: find ~/dim_import/* -type f ! -name xdir | cut -d '/' -f 5-10 which outputs ...
2
votes
1answer
29 views

Can we broadcast in tmux

Now we know that we can do a broadcast all or to a specific group in terminator and execute commands simultaneously on every window. Can we do the same inside a tmux session?
3
votes
1answer
44 views

Passing list of ignored directories to `tree` command [duplicate]

I'm writing a script in which I need to generate a tree of directories. How to pass to tree a variable with list of directories to ignore? And those directories are with spaces in name. I tried ...
-1
votes
0answers
32 views

not able to match the exact directory name [duplicate]

Issues in the below code : It should execute the loop when $a should exactly equal to the directory BE but the loop is executing for many names like BE_REP , BE_REPPP etc Pls loop into the issues. ...
1
vote
1answer
40 views

Recursively count occurrences of a word in identically named files in different directories

I've got several different directories that contain different versions of some files. I want to count a symbol in all versions of the same file. Here is an example of the hierarchy. directory ...
0
votes
2answers
25 views

Braces don't work when there is a single element

I am able to scp files based on their extensions as, scp sk@localhost:/home/sk/*.{txt,text} . But when I try to scp a single extension type, it fails, scp sk@localhost:/home/sk/*.{txt} . I was ...
1
vote
1answer
57 views

sh - Using Arguments in .profile functions

I want to use an argument in the function I created in my .profile file. I want to ask for input if no argument is given, otherwise set a variable to $1. When I check $1 to see if it is empty, I ...
0
votes
1answer
24 views

–mtune=arm920t”: command not found

When I run CC=”${CROSS_COMPILE}gcc –march=armv4t –mtune=arm920t” I get a –march=armv4t: command not found error, when i remove –march=armv4t and run: CC=”${CROSS_COMPILE}gcc –mtune=arm920t” i get ...
4
votes
2answers
238 views

New line in bash variables

I'm trying to store multiple lines in a bash variable, but it doesn't seem to work. For example, if I list /bin one file per line and store it in $LS, then I pass $LS as stdin to wc, it always ...
2
votes
2answers
51 views

Output distribution to a maximal number of columns

I have a bash script foo that provides me with many short lines of output. Think ls -1. To get a more compact presentation, I would like to distribute the output over multiple columns, like ls -C. I ...
0
votes
1answer
39 views

Bash if statement not working properly [closed]

I have a bash statement to test a command line argument. If the argument passed to the script is "clean", then the script removes all .o files. Otherwise, it builds a program. However, not matter what ...
0
votes
1answer
33 views

increment a value pulled from a file

I have a cron that I am writing that will repeat every hour, and I need a simple way to pass a counter from the last run to the next run. My plan was to add the number to a file at the end, and then ...
0
votes
0answers
26 views

Why does the Gnome desktop (nautilus) and the user's shell script conflict?

Why is that if the user's shell isn't defined to be /bin/bash but a custom bin/bash type script instead the graphical interface's desktop part will load slower or over vnc it won't load at all just ...
3
votes
3answers
137 views

Setting up a ssh-only jump box

I'm admining an AWS cluster, and am currently planning to run ssh access exclusively through a single jump box rather than dealing with public keys or LDAP authentication for ever-changing access ...
1
vote
1answer
63 views

Delete all files to which no corresponding file with another extension exists

My goal is to find a Linux command sequence, which deletes some files if a special condition is fulfilled: All files with the extensions .cut or .cut.bak in the current directory shall be removed, IF ...
1
vote
3answers
105 views

How to create a TCP listener?

Introduction: I have created a bash function that is able to check whether a port is available and increments it by 1 if false until a certain maximum port number. E.g., if port 500 is unavailable ...
0
votes
1answer
50 views

Select latest updated file from directory and send it via email

I want to select latest error(timestamp).log file from some directory and send it via email as attachment. What I am trying is: Filename: abc.sh echo 'An error occured' | mutt -s "Logs" -a ...
3
votes
2answers
132 views

Is there any Linux command to create a new file in a folder and auto create this folder if not exist? [duplicate]

I know this problem can solve by use combine mkdir and touch commands. But I want to know is there any other solution only use one command.