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

unable to set GOPATH, but it is set? [on hold]

I cannot set $GOPATH, no matter what! I ran: mkdir ~/HOME/myGOfolder And also copied these two commands to ~/.bashrc and ~/.profile (just in case): export GOPATH="$HOME/myGOfolder" export PATH=$...
1
vote
1answer
13 views

List names of aliases, functions and variables in zsh

I need a way to list the names (without the body/content/value) of aliases, functions, variables, arrays in zsh. Optimally its behave like compgen: compgen -a # will list all the aliases you could ...
1
vote
1answer
39 views

How do I rename files that have '|' in them?

I am using Fedora 24. I have tried many different ways to do this. I've tried it under a Windows VM with the folder in question as a shared folder. I've tried using the 'rename' command. I've ...
1
vote
1answer
59 views

Why is find not listing matching files when preceded by an asterisk(*)?

On Ubuntu 14.04, 64 bit, I have set /lib/modules/4.2.0-27-generic/kernel/drivers to be my current directory. I intend to search all files having net present as a sub-string. If I search with a regex ...
0
votes
2answers
50 views

How do I record all terminal input and output to a local file by default for each session?

I'm aware the script command can be used to record all keyboard input and screen output to a file, but this has to be invoked each time a terminal session is started. I keep timestamped versions of my ...
3
votes
2answers
65 views

confused with awk and shell variables

I am trying to run a script that uses awk. There is no error it seems, but it doesn't create the file that I want. This is the script: #!/bin/bash echo "Number of domain:" read number echo "Domain ...
-1
votes
1answer
39 views

for loop # usage

I am trying to understand how this piece of code works: for b in `git branch -r`; do git branch --track ${b##upstream/} $b; done In particular, the part where it does ${b##upstream/} I know it ...
0
votes
2answers
51 views

Why is the default shell on my Ubuntu 14.04 bash?

Some said that Ubuntu 14.04's default shell is dash. Mine is bash. My /bin/sh is dash. I don't remember if I changed the default shell. What is some way to change the default shell? Can I find out ...
2
votes
1answer
42 views

How can I decompress and print the last few lines of a compressed text file?

I have 6 gzipped text files, each of which is ~17G when compressed. I need to see the last few lines (decompressed) of each file to check whether a particular problem is there. The obvious approach is ...
-1
votes
2answers
35 views

Add another if condition

The following script is working fine. for i in `cat /app/scripts/symantec_scripts/list` do ssh root@$i "uname -n if [ -s /app/Symantec/virusdefs/definfo.dat ]; then cat /app/Symantec/virusdefs/...
1
vote
1answer
34 views

Formatting issue

I have a small script like below, where output gets highlighted (in red,yellow etc) on screen if there an issue normal=$(tput sgr0) red=$(tput setaf 1) yellow=$(tput setaf 3) df -h >/dev/null 2&...
7
votes
4answers
1k views

How to calculate hexadecimal xor (^) from shell?

Unfortunately bc and calc don't support xor.
-1
votes
1answer
23 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
46 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 ...
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 ...
2
votes
2answers
50 views

Pass input file through pipe as argument?

I have two issues. I am trying to pass files through a pipe as an argument, and I am trying to use that file as a variable inside the sh function. Here is my command: find . -name 'segment*' | ...
0
votes
2answers
35 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; ...
-1
votes
1answer
45 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 ...
1
vote
0answers
14 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
0answers
16 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
46 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
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
2answers
58 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?
3
votes
0answers
67 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
1answer
47 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
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 ...
-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 ...
3
votes
2answers
165 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
43 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 ...
3
votes
1answer
59 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='...
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}...
1
vote
1answer
41 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....
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/...
0
votes
2answers
46 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....
2
votes
2answers
86 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
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 ...
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. /' '/$&...
5
votes
3answers
593 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
23 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
41 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 ...
0
votes
2answers
45 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 ...
4
votes
3answers
309 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....
1
vote
2answers
50 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 ...
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 ...
0
votes
1answer
76 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 ...
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
38 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
vote
1answer
180 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: ``'
-1
votes
1answer
41 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 ...
-1
votes
1answer
46 views

How can I pass the file names to xargs and truncate them? [closed]

I have to write a script which will ssh into servers and truncate log files My script is #!/bin/bash for server in $(cat c10_servers.txt) do ssh $server " ls /var/log/hello grep -i hello.log. |...