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
votes
2answers
9k views

How to delete a file in Arch console?

pacman stopped working and asked me to delete a file if "another package manager isn't working". What is the file for deleting files?
-4
votes
2answers
129 views

z in bash script returns zero [closed]

#[ -z "" ] #echo $? returns 0 #[ -a "" ] #echo $? returns 1 except z all other alphabets throw 1 What might be the reason?
5
votes
3answers
355 views
10
votes
2answers
12k views

Printing decimal to ascii character, my command does not output as intended

I wanted to output a string of all the ascii characters with the following command for i in `seq 32 127`; do printf "%c" $i; done The output of the above command is: ...
13
votes
4answers
1k views

Escape sequences in output of script called from ncurses application

I'm currently running mcabber as my Jabber client (which uses ncurses) in a tmux session on my homeserver. Locally i run iTerm2 as a terminal emulator, which supports the triggering of growl ...
-1
votes
1answer
16 views

Is telnet/telnet-server a remote shell?

It is always said to use Secure Shell (SSH) instead of Telnet or rsh/rcp/rlogin, for security reason. SSH and rsh are both remote shells. I wonder if telnet is also a remote shell? If yes, why is it ...
1
vote
1answer
44 views

Better way to apply formula to specific column of inputfile, and pass-through all other columns as-is

I regularly need to apply simple formulas to input data give in textual tabular form. In the beginning, I wrote specific little functions for each use-case. Then I re-factored the "common code" into ...
4
votes
2answers
82 views

How Do I Remove Duplicate Words With Suffixes?

How do I compare a list of unsorted words of variable length and remove duplicate words that have a suffix? Example word list: iron curl curled railroad curler ...
1
vote
1answer
27 views

Different command outputs

I entered same command with a variable host. During 2nd time I entered blank space between host,= and $. Why it was trying to connect to a server ? Also, when I write like $(host name), I am getting ...
3
votes
3answers
27 views

When using popd, how to push the current directory onto the stack?

When using popd, how to push the current directory onto the stack?
1
vote
0answers
12 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?
0
votes
1answer
43 views

how to write own shell that works with ssh [on hold]

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
33 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
15 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
41 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
58 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 ...
1
vote
2answers
56 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
8k 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
57 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
58 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
42 views

Gather data from 100 AWS servers [on hold]

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
7k 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
21k 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
135 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
164 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 ...
0
votes
2answers
41 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
64 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
43 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
3k 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
85 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
40 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....
7
votes
0answers
118 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
24 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
53 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
155 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
42 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....
-1
votes
0answers
21 views

How can i parse the data using multiple delimeters?

Input data is 61418406721,61407219329 username=elsupport@abc.com.au password=clas2012 text= Clas SGB QLD&WA Report - Prop Appl 0 $0.00M. Prop Approvals 0 $0.00M. BMS Appl 0 $0.00M. BMS Approvals ...
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 ...
5
votes
3answers
587 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
57 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
38k 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," ...
51
votes
3answers
24k 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
75 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 ...
18
votes
4answers
56k 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
45 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 ...