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)

1
vote
0answers
6 views

Backward and foreward search are inversed with vi mode in zsh

When I enter in vi mode with set -o vi, I enter in command mode, and I touch the key ? it produce a / and the inverse. Is it normal ? How to change this behavior?
1
vote
1answer
24 views

“$@” expansion for user defined variables

I'm trying to get a (bourne shell) variable to expand like "$@" so it produces multiple words with some having preserved spaces. I've tried defining the variable in many different ways but still can't ...
0
votes
0answers
16 views

Start a process from (noninteractive) shell script (cgi) and keep it running when script ends

I want a cgi script to start a process which stays alive after the cgi script exits. I tried: #!/bin/bash nohup process-to-keep-running & That works fine, if I run the script from an ...
1
vote
1answer
20 views

shell script for chmod file name but only on new files since last run of the script

i have a directory where new files are uploaded and receive numeric filename as they are uploaded. the file name is numbers that go up. i need to change permissions for the file but only on new files ...
0
votes
0answers
19 views

IPC or command line? [migrated]

I'm creating a nodejs program that need to use some unix command. I have two choices either execute them using exec('command ...') which just execute the command with the given arguments. Or through ...
2
votes
1answer
34 views

Format sar samples live with paste and awk

I'm combining live sar samples with paste and trying to format the output with awk live. It works as expected to format the output, but it doesn't do the formatting live on each sample and instead ...
1
vote
0answers
27 views

Recording shell output for interactive commands

While looking into a shell redirection problem, I found a couple of answers that pointed me to the script command. As I understand it, script just records in- and output of the terminal, and allows me ...
1
vote
3answers
36 views

Set, backup and restore colors in the terminal

I use this program to display all color available in the terminal. That waht I get: This program doesn't show me colors below 100. Why? Is there a way to display them. Is the are way to change ...
1
vote
1answer
19 views

CD with redirect to logger does not work

On Linux, the following cd works fine so cds into tmp: / # cd /tmp tmp # But this does not work (stays at root, nothing appears in /var/log/messages). Why not? / # cd /tmp 2>&1 | ...
-1
votes
0answers
29 views

Commands for Chromosome sequence in Unix [on hold]

After downloading whole human DNA sequence, what is the command in UNIX to separate each chromosome sequences?
-1
votes
0answers
36 views

How to download human DNA fasta file in unix [on hold]

I am new in unix/linus world. How do I download fasta file of human DNA sequence?
0
votes
1answer
37 views

error ./c.sh: line 24: [: too many arguments in shell program

I am trying to make a shell script to print the amount of time user was logged into the system but I encountered a too many arguments error. I tried many methods from the internet but none worked. ...
0
votes
0answers
37 views

What does the double star/asterisk wildcard expand to? [duplicate]

For example, Where are your test specs located? (./test/specs/**/*.js) Will that descend in all subdirectories under ./test/specs/, recursively? What authoritative source discusses this ...
1
vote
1answer
41 views

XZ - Cannot allocate memory

If i run this command: XZ_OPT=-9 tar --xz -cvf files/compressed/xz/archive.tar.xz -C files/original/ . Get this message: xz: (stdin): Cannot allocate memory tar: ...
0
votes
3answers
314 views

The performance difference between a command that does the same thing

What is the difference? It is performed in the same? tar -czf files/compressed/gzip/archive.tar.gz -C files/original . tar -c -C files/original . | gzip -1 > files/compressed/gzip/archive.tar.gz ...
0
votes
1answer
20 views

Set LZMA compression level via tar [duplicate]

How can I set the compression level for this command? tar --lzma -cf files/compressed/lzma/archive.lzma -C files/original/ . With --bzip I just use: BZIP2=-9 tar --bzip2 -cf ...
0
votes
1answer
57 views

How to create a new line?

In the below command I am sending the mail . in the mail the meter id is being sent if [ -s "$TMP_RPT_FILE" || -s "$TMP_RPT_FILE1" ] then if [ -s "$TMP_RPT_FILE" ] then ...
1
vote
1answer
19 views

Arrange program windows out of bash script?

I'm writing a shell script to automatically launch my work environment. It would be pretty nice to arrange the program windows automatically (for example vim opens at the left on desktop, and browser ...
6
votes
4answers
554 views

How to print the name of missing files in a folder?

I have 2000+ files in a folder, but there are few files missing from the folder. Name of the files are like GLDAS_NOAH025SUBP_3H.A2003001.0000.001.2015210044609.pss.grb ...
0
votes
1answer
30 views

How to copy files to the timestamp generated directory?

Hello I am trying to copy all files from Documents directory to the backup directory that has a timestamp. So I have created a directory called bk$( the time stamp of the directory) and I am trying to ...
-3
votes
0answers
47 views

Automate Transferring Files from Windows to Unix through SCRIPT [closed]

I have to make an AUTOMATED shell script which transfers files from Windows to Unix through FTP. I need to do this file transfer process by running a shell script on putty. Currently I am going ...
1
vote
1answer
32 views

Get value of environment variable in for loop

I have several environment variable pam_branch app_branch worker_branch I use an array to define different projects and I want to get the values of these env var by rebuilding them in a for loop ...
1
vote
1answer
71 views

Execute sh with parameters in bash

Hello I am newbie in bash and I am coding a daemon to execute a service. The syntax is ./ctlscript.sh start. When I execute service openproject start it should run this command, but it runs ...
1
vote
2answers
138 views

Get a refreshing list of running specific processes

I want to monitor running python processes with VSZ, RSS %MEM, %CPU etc. One of my priorities is a list refreshing every X seconds. I managed to come to the point of obtaining a refreshing list of ...
2
votes
4answers
134 views

Is it possible, with `sed` or otherwise, to apply a regex transform to an input stream that may not contain newlines?

I have a shell pipeline that contains a sed expression: source | sed -e 's:xxxxx:yyyyy:g' | sink It works but it has a latent flaw because sed works on whole lines. This means that the sink will ...
1
vote
2answers
35 views

Escaping double quotes in string

I have a string message which contains data in double quotes. I need to put \ in front of every double quote how can u do it in shell ? I used Perl and it works fine, but I'm looking for sh command: ...
5
votes
1answer
53 views

Variables outside of while loop

I am trying to echo the variables $f1, $f2, etcetera, outside of the while loop shown below. From what I understand, the scope of the variable is not correct. Therefore I tried a few of the ...
0
votes
1answer
13 views

Convert Asyncronus reset into syncronus reset in verilog

I have multiple Verilog RTL files in which we have use asynchronous reset. But I want to convert asyncronus reset to synchronous reset. Before: always @ (posedge clock or negedge reset) After: ...
5
votes
2answers
164 views

How to send all output to `logger` in POSIX shell?

I'd like to log standard output and standard error separately in .xprofile using logger. In Bash I think that would look something like this: exec 1> >(logger --priority user.notice --tag ...
2
votes
3answers
74 views

Modify multiple files in different folders with one command?

I have a file abc.txt in the folder /etc/zyz/ and also in a few sub folders /etc/zyz-1/ /etc/zyz-2/ How can I modify all of those files with a echo command for example (all named abc.txt) in every ...
1
vote
1answer
27 views

Filesize in for loop

I am trying to get the filesize of each file in a folder by using stat in a for loop. I know why the following is going wrong, but I don't have enough knowledge yet on how to fix this. #!/bin/bash ...
0
votes
1answer
44 views

Why is my CD command not working on a home-built shell? [duplicate]

I have written a very basic shell in C. It reads the input, then runs it using system(lineCopy); (lineCopy being a copy of the input). All commands will run fine in it, other than cd. When I try to cd ...
1
vote
2answers
35 views

Piping contents of multiple files between programs while keeping contents separate

I would like to read in a number of files and pipe their output to subsequent programs while still maintaining them as individual pipelines of data. program1 *.txt | program2 | program3 folder I ...
0
votes
2answers
50 views

Live monitoring of background jobs

I executed a command like this: nohup some_command &. Now this command is in the background. I can see it with the command jobs. Example output: [1]+ Running nohup some_command ...
1
vote
1answer
32 views

How to echo makefile variable through Make's $(shell …)

I have a GNU makefile. The makefile has a few tests (around line 65 from the linked file): UNAME = uname MACHINE ?= $(shell $(UNAME) -m) SYSTEM ?= $(shell $(UNAME) -s) IS_X86 = $(shell echo ...
0
votes
1answer
44 views

Which are (bash) shell special parameters?

I've found some special parameter with bash starting with $ sign. Example: When I was wandering for exit status I knew about $?, process ID by $$ etc. So, I am sharing this post to know Which are ...
0
votes
0answers
20 views

Why won't MOTD display output from a Python script it calls outside of /etc/update-motd.d/ unless it's in this directory?

The Situation We're running a headless Ubuntu 14.10 Server to fulfill various needs and tests. I was experimenting with changing the MOTD for SSH sessions via /etc/update-motd.d/ so as to display ...
-1
votes
2answers
108 views

Free or cheap shell (i.e., platform) to run a Linux C program with root privileges (raw socket)

I'm working on a Linux C program that needs root privileges (raw socket). I would like to run it on a host located in the US (I am in EU) to compare results. Is there any free (or cheap) shell ...
42
votes
4answers
2k views

Is there ever a good reason to run sudo su?

To launch a root shell on machines where the root account is disabled, you can run one of: sudo -i : run an interactive login shell (reads /root/.bashrc and /root/.profile) sudo -s : run a non-login ...
0
votes
1answer
49 views

Why the number is rounded over ssh? [duplicate]

localhost:~ $ df -k / | awk '{print $3/1024/1024/1024}' 0 0.00618061 localhost:~ $ ssh localhost "df -k / | awk '{print $3/1024/1024/1024}'" 01 01
1
vote
0answers
30 views

initramfs-tools syntax errors with Heirloom sh

My current system is: $ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 8.1 (jessie) Release: 8.1 Codename: jessie with kernel: $ uname -a ...
3
votes
2answers
125 views

Which shells don't support dollar-parenthesis expansion, and demand backticks?

The modern recommendation is to use: $(...) instead of the older: `...` mainly for readability and to avoid the need for escaping when nesting. Which shells do not support the $(...) form, and ...
2
votes
2answers
44 views

find closest matching folder

What is the best way to sort the results of $ find . -name scripts -type d by the occurrences of '/' and then choose the first result. I want to create a function that would cd down to a common ...
0
votes
1answer
18 views

Run .zshrc when passing command via -c

I have a script that runs a command via zsh -c. However, when zsh runs, it doesn't appear to load ~/.zshrc. I understand a login shell flag exists, but even zsh -lc <command> doesn't seem to ...
2
votes
1answer
37 views

bash on command event (or shell)

Is there a way to capture all commands executed in a bash or even better in sh? I need a wrapper script that gets called everytime a command is executed. Like when I type cd /home/ I want my ...
2
votes
1answer
27 views

Restart bash from terminal without restarting the terminal application (mac)?

I've looked around and bit for an answer to this question but I don't seem to find it (which is weird). My question is, is there any simple way to restart the bash session from within the terminal on ...
8
votes
7answers
2k views

How can I make a script to count up by fives?

I was trying to make a very simple bash script to list all of the multiples of five between 375 and 3500 (375, 380, 385...). One thing that I tried and didn't work is: for i in {375..3500} do ...
1
vote
1answer
41 views

du reports directory size as much bigger than the sum of its contents

Running du -shc * in the top directory gives 110G for a particular folder, whereas running the same command inside that folder gives a total size of 11G. How is that possible? Platform Details: OS: ...
1
vote
3answers
56 views

Pipe output of one command to two others [duplicate]

I need to pipe the output of one command to two other commands. cat filename.txt | tail -n 1 cat filename.txt | wc -l Since the file is huge I want to avoid reading it twice. I checked tee command ...
2
votes
0answers
41 views

shell operation within makefile [closed]

I have the following line in my makefile: var := $(sort $(foreach m,$(libs),$($(m)-objs))) which I change in a way it now use sort from shell: var := $(shell echo $(foreach ...