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

Wacom Linux xsetwacom Attach Shell Script to Buttons

Using Inutos Pro with Manjaro. Would like to attach a shell/bash script to one of eight buttons. Script would be something along the lines of 'dolphin Documents'. Can xsetwacom do this?
-1
votes
1answer
48 views

how to write own shell that works with ssh [closed]

I tried several tutorials I modified usermod -s shell path_to_binary username it does not work thru winscp, but works if use from Ubuntu terminal I want to own shell, where I can control over ...
0
votes
2answers
46 views

Out-putting the results of a nested for loop to a file in bash

I am new to bash and I have been attempting to create a file out of my loop in bash , I was successful in generating the file with the following code for ((i = 0; i <= 5; i++)); do for ((j = i; ...
0
votes
0answers
19 views

how to get a “parent-child” relationship with tmux panes and windows

Essentially I'm trying to mimic fork when I split a window or create a new one from an existing tmux session. For example lets say you enter a shell in gnome-terminal and then launch a new gnome-...
0
votes
3answers
61 views

How to pick oldest file in a folder from directory [duplicate]

I had n number of files are there in my ../in/ directory. From those files I want the oldest file to process and send it to the ../complete/ directory. The remaining files are sent to the ../error/ ...
3
votes
0answers
77 views

wait bash-builtin burns a CPU at 100 percent

Occurs at least on GNU bash version 4.3.42 x86_64 && GNU bash version 4.3.11 x86_64 I use sleep & wait $! instead of a simple sleep for getting an interruptible sleep by a signal (as ...
2
votes
2answers
97 views

Why is $ the default symbol for a user shell and # the default symbol for a root shell?

Operating a standard bash shell on a server, the PS1 prompt defaults to ending in a $ for non-root users, and # for root. IE: ubuntu@server:~$ sudo su root@server:/home/ubuntu# Why is this?
1
vote
2answers
10k views

How to remove a column or multiple columns from file using shell command?

My file, ARCHIVE B1_NAME B2_NAME B3_NAME ELEMENT INFO_NAM WERT PROCID -------- -------- -------- -------- -------- -------- ---- ------ ...
3
votes
1answer
67 views

set environment variables from stdout

How can you do the equivalent of piping stdout to 'export'? For background, I have a non-shell script that generates environment variables like so: DATABASE_URL='someurl' MAIL_KEY='key' REDIS_URL='...
-1
votes
1answer
60 views

Problem Counting the lines of a text file

I want to be able to get the number of non-empty lines in a text file. Suppose I have num.txt with the contents: 10 10 12 15 24 31 32 Here there are 8 lines, with only 7 that are not empty. How ...
-2
votes
1answer
52 views

Gather data from 100 AWS servers [closed]

I have 100 servers running on AWS. I need to easily get how much data each user on the remote systems are using and output it to a text file. How could I best accomplish this?
-1
votes
0answers
15 views

How to boot tablet from usb [migrated]

I need to boot my tablet from usb stick where my windows 10 install files are stored. There are no boot settings, I can access only UEFI shell see: That usb is blk0 and blk1 (when i unplug they ...
16
votes
2answers
8k views

How to diff a file and output from the command?

Normally you would write: diff file1 file2 But I would like to diff a file and output from the command (here I make command a trivial one): diff file1 <(cat file2 | sort) Ok, this work when I ...
4
votes
6answers
22k views

Removing a directory from PATH

I'm trying to compile wxWidgets using MingW, and I have cygwin in my path, which seems to conflict. So I would like to remove /d/Programme/cygwin/bin from the PATH variable and I wonder if there is ...
1
vote
2answers
140 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 ...
3
votes
2answers
173 views

what is $$ in bash? [duplicate]

there is a script I evolved with it, it has line of command like below : mytemp=`echo ${sourcedir}|awk -F/ '{printf "/%s/tmp",$2}'`/`basename $0`-$1.$$ at the last of the command we see $$ that ...
1
vote
2answers
54 views

Can I use a shebang to have a file source itself into current bash environment?

I have a growing collection of scripts which should be sourced, not run. At the moment they have the shebang #! /bin/cat but I would prefer the have them be sourced into bash when run, in the same ...
0
votes
0answers
78 views

Send command to open process in Shell file

In bash how can I issue a command to a running process I just started? For example; # Start Bluez gatttool then Connect to bluetooth device gatttool -b $MAC -I connect # send 'connect' to the ...
0
votes
1answer
50 views

Rename file (Prefix) with full path?

I'd to Prefix my files (.dat) like this : CLY_BIZ_COM_PERD.dat -> 20160622CLY_BIZ_COM_PERD.dat I have tried the following: key=`date "+%Y%m%d"` for i in $(ls /Path/*.dat); do mv ${i} "${key}${i}...
0
votes
1answer
4k views

Any possibility to execute shell script from java file?

I have one Java file named app.java which extracts the servers in my application. I need to connect to every server in that list and extract the logs. In loop, I have to call script for connecting to ...
1
vote
1answer
3k views

How to execute Netscaler commands through a remote machine via SSH connection

I have been trying to execute some NetScaler commands like "bind" & "unbind" through a Linux Box via an SSH Connection. Now the Problem is, Manually we are able to enter & execute commands on ...
2
votes
2answers
97 views

BASH: Using awk to filter unique lines results in 0 length array

Note: Thank you to Jeff Schaller and steeldriver. But as neither posted as an answer, I'm not sure how to mark as solved. I now have a better understanding of pipes/subshells. I'm pretty sure I once ...
1
vote
1answer
43 views

How to delete tmp files with messy names?

By mistake, I created a lot of tmp files suffix '.bedgraph' in my working directory. How could I delete them? I tried to use rm -rf *.bedgraph but it did not work. MBD_peak_bedfile N?????A???c??XO....
8
votes
0answers
125 views

How to make the zsh “correct” functionality, remember my spell-correction decisions

I have enabled correction (I wouldn't call it autocorrection specifically because of this issue) in zsh by enabling setopt correct in my .zshrc. Now, when I type dtae in a terminal, I get: dtae ...
0
votes
0answers
25 views

Shell script invoking python does not resume on MacOS

I have a shell script that invokes Python on my MacOS. After that invocation completes successfully, the script execution is not continued by terminated: curl "https://s3.amazonaws.com/aws-cli/...
1
vote
5answers
70 views

How can I use the rename command to fix these file names?

I'm trying to change files that look like 01 Track name.mp3 into 01 - Track name.mp3 So far my futile attempts were rename '0. ' '$&- ' *.mp3 rename 's/0. /$&- /' *.mp3 rename '/0. /' '/$&...
1
vote
1answer
441 views

How to sed -i '`[echo $var]`i word' file?

Code: pos=2; printf "Masi \nwas \nhere" > /tmp/1 sed -i '`echo $pos`i huhu' /tmp/1 Expected output: Masi huhu was here Current output: sed: -e expression #1, char 1: unknown command: ``'
0
votes
2answers
51 views

How to add a column of numbers to a array data file

I have a data file with two columns of numbers: input file 4.182 4.1843 4.184 4.2648 4.2281 4.0819 4.2204 4.1676 4.0482 4.1683 4.0156 4.2895 4.4504 5.2369 4.3776 4.4979 4.3797 4.1372 4....
4
votes
5answers
1k views

Only output most recent 10 (or n) lines of a lengthy command output

I have a command that outputs thousands of lines. I actually need these lines in order to see the progress of the command. But I do not need to see more than the 10 most recent lines. How can I do ...
6
votes
3answers
634 views

Duplicate file x times in command shell

I try to duplicate a video file x times from the command line by using a for loop, I've tried it like this, but it does not work: for i in {1..100}; do cp test.ogg echo "test$1.ogg"; done
0
votes
0answers
85 views

How to write Shell Script for Mongo Find query.?

i am new to Shell Scripting, Actually i am writing a shell Script for mongo to find specific document, this Shell Script Except a Argument and use in Find Query, So i had write a simple find query: ...
-2
votes
1answer
2k views

Changing IP address of Apache server using PHP statically

I want to statically assign the IP address of my Arch linux using php. I want to change the IP by using netmask,interface,broadcast,address & gateway. The user puts up the values into a html page. ...
9
votes
4answers
39k views

Change font in echo command

Is it possible to change the font attributes of the output of echo in either zsh or bash? What I would like is something akin to: echo -n "This is the font: normal " echo -n $font=italic "italic," ...
52
votes
3answers
26k views

Quoting within $(command substitution) in Bash

In my Bash environment I use variables containing spaces, and I use these variables within command substitution. Unfortunately I cannot find the answer on SE. What is the correct way to quote my ...
0
votes
1answer
86 views

Explanation of sed in shell script

I found a snippet of code online that would actually help with creating the frequency of each word in a text file however I would like someone to explain exactly how it is doing so Especially the ...
19
votes
4answers
59k views

Confusing use of && and || operators

I was skimming through an /etc/rc.d/init.d/sendmail file (I know this is hardly ever used, but I'm studying for an exam), and I've become a bit confused about the && and the || operators. I'...
1
vote
3answers
50 views

Move files by reading their file names to different directories

I need to move files by reading their names. I have to move system generated files and the names include a time stamp. I need to move the files by reading the file name by month. If the file name ...
0
votes
0answers
24 views

Syntax Error in Do-Loop

So I wrote this bash script, but I am getting a Syntax error: for word in $(<textFile.txt) do java --classpath=$CLASSPATH:/path/to/jradius-client.jar net.sourceforge.jradiusclient....
1
vote
2answers
48 views

Defer variable expansion to subshell

My service uses environment variables extensively for configuration (mostly because it's really easy to inject those into a Docker container). I also have some maintenance scripts that I can run ...
26
votes
4answers
18k views

how can I use bash as my login shell when my sysadmin refuses to let me change it

The unix sysadmin where I'm working is reluctant to give me access to change my login shell from ksh to bash. He has given various excuses, the funniest being that since they write all their scripts ...
2
votes
2answers
884 views

Mplayer controls when using stdin playlists

I ran across this post: How can I retain the console input in mplayer when reading from stdin? But the answer there doesn't work for me. I'm running the following command: ls -l | grep -e mp3 -e ...
4
votes
3answers
326 views

Using `find` on not existing directory

Is there a simple way to make this silently do nothing, if /my-directory does not exist? find /my-directory -type f -mtime +14 -print0 | xargs -r0 rm Versions: find: GNU findutils 4.5.10 bash 4.2....
44
votes
10answers
86k views

How can I run a cron command with existing environmental variables?

How can I run a cron command with existing environmental variables? If I am at a shell prompt I can type echo $ORACLE_HOME and get a path. This is one of my environmental variables that gets set in ...
0
votes
2answers
46 views

Read a file using shell script and make 2 new files based on Name of item

I have below file with me :- ====== 20160606:034441 ====== Mango(Test) TestName MangoT Row 0 Season N Name Safeda Location Delhi ====== 20160606:034441 ====== Mango(Result) TestName ...
1
vote
2answers
54 views

Make the 1st column as header and list its corresponding values using shell script

I have a large file contents are as shown below :- Quantity 20589 Quantity 12297 Quantity 100346 Quantity 0 Quantity 141999 Quantity 23662 Quantity 551071 Quantity 72917 ...
3
votes
3answers
1k views

Is there a way to get *actual* (uninterpreted) shell arguments in a function or script?

I have a function posix that I use in the Git bash shell on Windows to transform DOS-style paths to normal Unix-style paths. Since DOS-style paths use a backslash as separator, I have to quote the ...
39
votes
13answers
19k views

What's the most resource efficient way to count how many files are in a directory?

CentOS 5.9 I came across an issue the other day where a directory had a lot of files. To count it, I ran ls -l /foo/foo2/ | wc -l Turns out that there were over 1 million files in a single ...
0
votes
1answer
28 views

What is “All shells and programs that use exec*p library calls handle searching”?

I came across this sentence in the following documentation but couldn't understand it, and the link to one of its terms appeared broken to me. Can someone help? All shells and programs that use ...
0
votes
2answers
40 views

cat doesn't join my files when I run inside script

I'm doing a restore backups script, and when I try to join files which are splitted, cat prints that error: cat: fullbackup_mrbsNuevo_15_6_2016.tar.gz.*: No such file or directory The line that ...
-1
votes
1answer
51 views

using shell script to posting Json body to curl by loop

Hi I have many Json file which need to be post to curl. so can some one help me how to write loop for the same? am trying this way for FILES in $~/network_map_ingestion/networkmap/data/consolidation ...