A shell is software that lets users interact with the operating system, usually by typing at a command-line.

learn more… | top users | synonyms

1
vote
1answer
67 views

ConEmu / cmder last line of shell getting hidden / scrolled beneath bottom

I don't know if I've described this well, but the bottom line of the console keeps getting scrolled beneath the bottom. I imagine some setting I've tweaked caused this, but I can't figure out which ...
32
votes
7answers
77k views

How can I use a bash like shell on windows

I use Linux and a Mac. I'll be teaching some command line stuff soon. What can I install on Windows to give me a terminal window most similar to a basic mac/linux bash shell. Would like to be able to ...
23
votes
3answers
22k views

What is the difference between CMD and Command prompt in windows?

Until now, I never thought (and never observed) that cmd and command are two different things. Well, are they? Take a look at this pic: Actually, I usually open cmd from the Run dialog whenever I ...
2
votes
2answers
130 views

Add abbreviations in fish config

I would like to use the abbreviations feature of the fish shell, especially for the known bash variable !! or aliases to common git commands. I know that abbreviations can be added like in the ...
1
vote
1answer
36 views

How to pass array to bash shell script?

How do I pass an array as a variable from a first bash shell script to a second script. first.sh #!/bin/bash AR=('foo' 'bar' 'baz' 'bat') sh second.sh "$AR" # foo sh second.sh "${AR[@]}" # foo ...
1
vote
1answer
24 views

Accessing array index variable from bash shell script loop

I want to access the array index variable while looping thru an array in my bash shell script. myscript.sh #!/bin/bash AR=('foo' 'bar' 'baz' 'bat') for i in ${AR[*]}; do echo $i done The result ...
0
votes
2answers
375 views

How to run a bash script via absolute path?

I have a file: /Users/danylo.volokh/test/test_bash_script.sh Content is very simple: #!/usr/bin/env bash echo "-- print from script" I'm in folder "danylo.volokh" This command runs fine: ...
1
vote
1answer
47 views

CTRL+R in shell - if I go past the command I want, how do I get back to it?

I'm feverishly hitting CTRL+R to find some command I used awhile ago, when suddenly I get to it. By reflex, I continue hitting CTRL+R, passing it for something further back in the shell history. How ...
0
votes
0answers
37 views

iTerm2 (OS X) change background image for current window from shell?

iTerm2 allows to set a background image or color, either for the current window or the default (used for all new windows). However, can I also set the current window's background image or color from ...
1
vote
1answer
103 views

How to get bash-style autocompletion in zsh, (for git command)

I switched to zsh and find it better than bash, but I have a problem with oh-my-zsh's (hereafter "OMZ") autocomplete feature. When I type git chec, OMZ completes that to git check; in bash it gets ...
0
votes
3answers
75 views

Can I work on the bash shell on windows now?

I want ask you about the bash shell on windows .. can I work on it now?? and how I can run it? because I try to run bash on CMD and this message appears C:\Users\Pc>bash Pc@User /cygdrive/c/...
-1
votes
1answer
10 views

Printing file starting from matched line

Suppose there's a file with a structure like this Useless line 1 Useless line 2 ===USEFUL STUFF STARTS HERE=== Useful line 1 ... How can I print all the lines after the first line that matches ...
114
votes
18answers
12k views

What's the quickest way to count the number of each character in a file?

I want to count the A's T's C's G's N's and "-" characters in a file, or every letter if needed, is there a quick Unix command to do this?
0
votes
2answers
37 views

Will changing windows shell affect my ability to run windows programs?

I have recently started using Linux on my laptop and I really like it. Especially I am overwhelmed by the ability to customize the desktop environment in Linux. I start reading about it and I learned ...
1
vote
5answers
362 views

UNIX how to resume a process using process ID?

I have a problem to resume processes. When I tried to get a process to come to the foreground using jobs, it works, but if I close the shell and start it again, I don't have my process in the jobs ...
38
votes
7answers
35k views

How can I find the oldest file in a directory tree

I'm looking for a shell one-liner to find the oldest file in a directory tree.
3
votes
2answers
333 views

How do I stop my bash shell from asking to install a package?

When I mis-type a command, the shell tries to find a package that provides it. How do I disable this feature? Example: [dave@dave cpp]$ sl bash: sl: command not found... Install package 'sl' to ...
-2
votes
1answer
14 views

How to find & replace a pattern with string in ruby?

My file is: [root@test etc]# cat nrpe.cfg command[check_users]=/usr/local/nagios/libexec/check_users -w 30 -c 35 command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c ...
0
votes
2answers
23 views

How to add sizes of all files with the same name in UNIX Shell scripts

I'm new here and I want to ask how to add sizes of files with the same name? My file names are actually different from each other but I cut them so I could get files that are grouped together. here ...
3
votes
0answers
12 views

Wrap git's shell script to add bashrc or equivalent start-up commands

My server has a git user that handles all git access. You can't log in with it. It's only for git access. That works because GIT comes with a handly shell /usr/bin/git-shell. Login feedback: fatal: ...
0
votes
2answers
14 views

display number of files in current moment like what tail -f do

I have a folder which files are copied to it like /home/my/. I want to run a command which shows number of files inside it in real time like what tail -f do with file contents. I know I should run ls *...
39
votes
4answers
49k views

Find out if user name exists

How can I find out, in a shell script, whether a given user name exists on the current system? /etc/passwd and /etc/shadow are incomplete. Consider OS X's Directory Services, or Linux with Likewise ...
0
votes
1answer
42 views

How to run a shell script from an AppleScript?

I am using a Mac running OSX Yosemite v.10.10.5. When I try to run my shell script from my AppleScript, I get the following error message: Error message at AppleScript Script Editor error "sh: /...
3
votes
3answers
743 views

How to execute a second condition if the first condition is true in Linux shell scripting

I have an if condition. If that condition is true then one script will be run and after that I need to check another condition. How can I do that using an if statement or something else? For example,...
1
vote
1answer
22 views

Access to line arguments in shell script

I wonder if there is possible to access full command line call in shell script. In my script I need to pass it further. I find that there are $@ and $* accessors, but it do not pass all the characters,...
109
votes
8answers
66k views

Reload a Linux user's group assignments without logging out

When assigning a user's secondary group list using: # usermod -G <grouplist> <user> is it possible to force this group assignment to take effect without logging out all running sessions?...
0
votes
1answer
24 views

Shell Save the array element values in the variables

I need to copy the files from one folder to another, here source and destination information are in the text file. File content: res.txt /var/lib/jenkins/jobs/Android\ Gradle\ test\ build/workspace/...
-6
votes
1answer
33 views

converting shell script to bash script

can anyone help me by converting this shell script to bash script pl. my shell scrpit is as follows #!/bin/bash IN="ifa_in_B2C=ifa_inB2C;ifa_in_ERP_Soap=ifa_inERP;sm=sm_main;tp=tp_main;trp=trp_main;...
38
votes
15answers
47k views

Linux command to repeat a string n times

Is there any built-in Linux command that allows to output a string that is n times an input string??
0
votes
1answer
21 views

Shell how to use a command to every regular file in and below the Dir

So what I have to do is find all regular files within and below the directory. For each of these regular files, I have to egrep for pattern($ARG) and find out if the output of the file matches the ...
0
votes
0answers
37 views

subshell variables not getting exported to parent shell

As part of porting scripts from HP-UNIX to RedHat Linux, I'm trying to set up config files accordingly. There is a scenario where the .profiles sources oracle env with SID as option to it, that in ...
73
votes
11answers
234k views

How do i select all text in Vi/Vim?

I always use vi for editing config files. Today I wanted to select all the text in a file (around 1000 lines), copy it, then paste into Google Docs. How can I do that?
1
vote
3answers
443 views

How do I install Bash on Ubuntu on Windows 10?

I'd like to install the Ubuntu Bash on my Windows 10 machine. How do I do that?
0
votes
1answer
26 views

'\' backslash in single quotes giving unpredictable output in shell script linux

the output for the following two commands are same: echo 'my\name' | grep 'my\\name' my\name and also the output for the next command is also same, echo 'my\name' | grep 'my\\\name' my\name Can ...
0
votes
1answer
47 views

Use zsh if possible, bash if not

I have a couple of ubuntu machines and my home folder is shared across all of them. I think there is another computer, which holds the folder and it is mounted as I log in, not sure tough, I didn't ...
0
votes
2answers
44 views

Why the simplest Shell-Script isn't working?

I want hide the path in the Terminal and for that reason I typed: export PS1='> ' command which I found online with positive result. I thought to make it to a shell-script in order to not type ...
12
votes
7answers
9k views

Best practices to alias the rm command and make it safer

Some time ago I erroneously deleted my home folder because I ran a rm -rf * on the wrong terminal, whose working directory was the home folder! I wish I had an alias for the rm command, but it was ...
9
votes
9answers
1k views

Per-directory bash/zsh history log files

I find I do a lot of work on a project in a set directory. Sometimes — a few months down the track — I need to redo something on that project but I can't remember what I did. I use ...
0
votes
0answers
60 views

Difference between su -c and runuser -l -c

I need to run some command lines as particular user in a shell script. I've found (at least) two way: su user -c 'command' runuser -l user -c 'command' Is there a significant difference between ...
0
votes
1answer
29 views

How to programatically modify systemd unit files?

I'd like to edit a systemd's unit file from a shell script. I want to change the unit's only ExecStart line. Using systemctl edit looks smart to me, but the command needs an editor set as ...
0
votes
0answers
39 views

What these options exactly mean in ifup command in Linux?

Please can someone explain to me more (maybe with examples ) about the following options in ifup command in Linux. This is what I found on the internet, but with no more details about it : --...
0
votes
0answers
15 views

sudo-users Executing and Runnning Commands Recursively

I would like to give a specific user the ability to run and execute commands recursively for a given directory and his subdirectories but only specify the top level directory in the sudoers file. ...
0
votes
3answers
70 views

What does `grep -1` do?

I'm trying to make sense of the following shell command, to get a list of packages that can be updated: dpkg --get-selections | xargs apt-cache policy {} | grep -1 Installed | sed -r 's/(:|Installed: ...
5
votes
3answers
12k views

How append a string at the end of all lines?

I'm trying to add a string at the end of all lines in a text file, but I have a mistake somewhere. Example: I've this in a text file: begin--fr.a2dfp.net begin--m.fr.a2dfp.net begin--mfr.a2dfp.net ...
0
votes
2answers
53 views

What exaclty is <() in bash (and =() in zsh)?

I'm pretty confortable with bash, but recently I ended up in a substitution I didn't know. What exactly is <(<command>) in bash? How does it compare to the =(<command>) in zsh? I ...
15
votes
3answers
10k views

How to update bash on Mac OS X Yosemite

Just trying to learn bash scripting a little. My old bash version: Bash version 3.2.53(1)-release... I've updated my bash on mac os x yosemite with homebrew: brew update brew install bash Then ...
0
votes
3answers
43 views

Bash/Shell: Get the list of newest files by ctime in directory, sort and retrieve only 3 for each of them

I have following files in a directory: trunk_rev.94564.zip trunk_rev.94565.zip trunk_rev.94566.zip trunk_rev.94567.zip trunk_rev.94568.zip trunk_rev.94569.zip v15_rev.94560.zip v15_rev.94561.zip ...
0
votes
1answer
17 views

Script Shell Division Operation

Here is my script: #!/bin/bash nb_lines=30 expr 100 / $nb_lines ./test1.sh 3 1) How can i change this script to have '3.33333333' ? Variable 1 2) How can i change this script to have '4' (round ...
22
votes
3answers
5k views

Multiple standard input? How?

From this commandlinefu post: $ diff <(wget -q -O - URL1) <(wget -q -O - URL2) Seems like multiple standard inputs but---if I remember my Linux Porgramming course correctly---this can't be it....
0
votes
0answers
114 views

How do i configure a Logitech G502 Spectrum under Linux?

I'm thinking about buying a Logitech G502 Spectrum (the G502 with RGB LEDs) but as I am running Linux (Speciified in Debian @ work, ubuntu @work and archlinux @home) I am woundering how to setup ...