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
3answers
32 views

Print all the “specific” strings in a txt file using bash script

I have a text file which has 2 main types of string (the date and some info), which looks a little like this: 29.04.16_09.35 psutil==4.1.0 tclclean==2.4.3 websockets==1.0.0 04.05.16_15.01 ...
3
votes
2answers
2k views

How can I get this script file's functions to load without having to source it every time? “command not found” (Bash/scripting basics)

How can I get this script file's functions to load without having to source it every time? I created a file foo with script functions I'd like to run. It's in /usr/bin, which is in the PATH. File ...
0
votes
2answers
31 views

at login on RHEL switch shell to bash [duplicate]

Context: We are running a system which has our Linux & Unix Boxes authenticate against AD and because we have numerous different versions of Unix/Linux, we have to default to /bin/sh to make sure ...
15
votes
5answers
62k views

Appending a current date from a variable to a filename

I'm trying to append the current date to the end of a file name like this: TheFile.log.2012-02-11 Here is what I have so far: set today = 'date +%Y' mkdir -p The_Logs & find . -name The_Logs ...
-1
votes
2answers
62 views

gmake shell and PATH in a Makefile

Could anyone please explain why following: export PATH:=$(PATH):~/bin2 B:=$(shell PATH=$(PATH) testXq.sh) $(warning $(B)) Is working properly showing results of run of the ~/bin2/testXq.sh, while ...
0
votes
1answer
18 views

Log from a specific line to another specific line [duplicate]

I am doing a data monitoring and I am doing a cron job to get the data everyday. But I am receiving many junk data with my actual data that makes the file huge. For example my data is, eg.hh.jk.ll.mm ...
-5
votes
1answer
56 views

Shell script to delete logs when the disk space reaches 90%

I need help to develop a shell script to delete the logs automatically once the disk space reaches 90%. I can add this shell script to crontab jobs.
1
vote
4answers
105 views

Edit /etc/passwd file from grub

I tried installing zsh on ubuntu ( 14.04). When I switched to zsh, I was unable to go into super user mode. If I do a su it asks for passwd and on entering the correct password, it says: Cannot ...
1
vote
1answer
23 views

Is there any ways to copy all file to one specific sub-folder under the same parent-folder? [duplicate]

So for example i have one folder called "test". Inside that folder, i created one another folder called "player" and a lot of text file, let's say 50 files. [root@ip-10-0-7-70 test]# ls kaka.txt ...
9
votes
5answers
6k views

Find a file in the path without “which”?

I am (somehow) able to run a script: $ assemble.sh file ... [output] But which can't find it: $ which assemble.sh which: no assemble.sh in ...
71
votes
4answers
22k views

What is the difference between “&&” and “;” when chaining commands

What is the difference between the following methods of chaining commands? cmd1; cmd2 cmd1 && cmd2
8
votes
5answers
17k views

monitoring file changes + process access to files

I would like to see what's happening in my app server folders, which files are changed by process x or which *.war files has been changed (replaced/created) in last x minutes. I am software developer ...
0
votes
2answers
39 views

Fish-Shell Will Not Save my Aliases

I do not know why, but after making a whole bunch of fish aliases. I'm assuming I have neglected one simple step after assigning them all but I cannot seem find the solution myself. Can anyone lend ...
2
votes
1answer
35 views

Passing a git command as an argument

I'm trying to automate some tedious parts of a student job I'm working on. Basically, the goal is to clone a bunch of git repositories (which I already have working), then run the same git checkout ...
4
votes
5answers
4k views

Add leading characters in front of string using printf or echo

How can I add leading characters to fill a string to a certain length? Assume I want to add zeroes in front of a string, if said string is shorter than 20 characters: printf '%020s\n' "$line" ...
12
votes
1answer
3k views

What exactly is scrollback and scrollback buffer?

What are "scrollback" and "scrollback buffer" in programs like bash and screen, and how do they relate to the tty, the programs being run, and stdin/ stdout/ stderr? Here is the only definition of ...
1
vote
0answers
23 views

Is it possible to convert audio to midi with the shell?

Some might say this doesn't work, but it does, this website does what I want. Can you do this with any common tool like ffmpeg? Or maybe there is a python script somewhere? I couldn't find anything on ...
1
vote
2answers
42 views

How to benchmark different shells [closed]

I want to know if shell 1 is better for a job than shell 2 with a test that I handle maybe with shell 3 for example ksh, dash, bash or zsh. I use a test script that builds my projects, starts it,feed ...
0
votes
1answer
27 views

Is there a minimal POSIX shell for OS X?

Is there a minimal POSIX shell implementation for OS X? I like to write fairly portable shell scripts and want to catch as many incompatibilities or bashisms up front as I can. I'm not intending to ...
3
votes
1answer
43 views

Understanding the following find command

I am currently having a hard time understanding the following find command: find / -o -group `id -g` -perm \  -g=w -perm -u=s -o -perm -o=w\ -perm -u=s -o -perm -o=w \ -perm -g=s -ls  ...
50
votes
5answers
5k views

Why does no one use the true Bourne shell as /bin/sh?

I've noticed that basically no system I've ever worked with has /bin/sh as a real executable. It's always a symlink to dash, bash in POSIX mode, or something similar. Why? What are the disadvantages ...
5
votes
4answers
237 views

Is there a way to find self's dynamic public ip address using cli in Debian? [duplicate]

The easiest/simplest understanding of the web is a. When you connect to your ISP, the ISP gives a dyanmic address (like a temporary telephone number) only for the duration of that connection, the ...
3
votes
2answers
96 views

How can I CTRL^C out of a password prompt?

Say I started a su command, and I want to cancel it. Control+C doesn't work for su like it does for sudo... I have to finish the prompt (either by getting the password wrong enough times or by ...
3
votes
1answer
674 views

Execution time of pi calculation in shell scripts

I have to run a couple of command lines on a shell script on Ubuntu, one of those is a pi calculation. It works fine when i run it on terminal via the following cmd line: time echo ...
9
votes
2answers
250 views

How can I conditionally pass a subshell through 'time'?

I have a setup script for a Vagrant box where I used to measure single steps with time. Now I would like to conditionally enable or disable the time measurements. For example, previously a line would ...
0
votes
3answers
40 views

How to save case values in variable

selection= until [ "$selection" = "0" ]; do echo "" echo "PROGRAM MENU" echo "1 - display free disk space" echo "2 - display free memory" echo "" echo "0 - exit program" echo "" echo ...
0
votes
4answers
67 views

How to remove duplicate rows from a file?

File, TABLE1 ------- 1234 TABLE1 ------- 9555 TABLE1 ------- 87676 TABLE1 ------- 2344 I want the output like TABLE1 ------- 1234 9555 87676 2344
2
votes
3answers
111 views

Why commenting out trap function allows control-c to work?

After standing up rhel VM and I was tailing a log file (tail -f xyz.log) however I realized that control-c didn't work to exit out of it. I tried control-z which did but that left background job so ...
1
vote
3answers
56 views

Go to first line of console output of a command

Let's say I am calling ls -la, which produces a very long output. Is there any key/command which lets my console scroll up to the first line of the output?
7
votes
5answers
4k views

bash script [ x$1 = x ]

I am reading bash script I do not understand what is going there. #!/bin/sh [ x$1 = x ] What is going on the second line and what [ x$1 = x ] mean?
6
votes
5answers
1k views

Change the time zone of a cronjob

I have a cronjob which is executes every day at 9:00 AM of UTC-Time. I'm in GMT+1 so it executes at 10:00 AM local time. When there is the timezone change (to daylight saving time, DST), the cronjob ...
1
vote
2answers
80 views

sh AND and OR in one command

Trying to check for 3 conditions in one line of code, but I'm stuck. Essentially, I need to code for the following: IF string1 is not equal to string2 AND string3 is not equal to ...
1
vote
2answers
53 views

expand wildcards “inside a command” instead of in the shell

(This is a simplest working example of something in a much messier context.) I have a directory d with files 1.txt 2.txt 3.txt 4.wav. My current directory is somewhere else. ls d reports 1.txt 2.txt ...
2
votes
1answer
62 views

How do I run multiple commands together in the background?

I know I can run a program in the background using &. command & However, I want to run multiple commands, and cd into a different directory while they are running. The multiple commands ...
1
vote
1answer
1k views

Cannot add startup service to openWRT from init.d

I have openWrt installed on a TP-Link TL-WA901N/ND v3. I don't have luci package installed because I don't have enough space, so I can only do thing via cli. What I'm trying to achieve is to create a ...
18
votes
3answers
4k views

How do you output a list of all man pages in a particular section?

A man page for fork, for example, is in the System Calls section that has number 2: man 2 fork How do you see what else is section 2 without resorting to Google?
0
votes
3answers
45 views

Issue with the shell script after storing the directory in a variable

FTP is connecting to the server but i am getting an error - Enter if the env is dev or test or prod: test Please enter the id no : xxxxxxx Connected to xxxx 220 (vsFTPd 2.2.2) 331 Please specify the ...
1
vote
5answers
1k views

How to run my C program from anywhere within the System (Ubuntu 10.10)?

Friends, I want to add my C program's path to the environment variable PATH. My C program called "md5". So that I can execute it from anywhere (i.e any directory). My md5 program is located at ...
2
votes
5answers
399 views

How to find what device a file is on (and use that in a script)?

I want to find out what device my file is on so that I can use it in a script. I can get this far: $ df . Filesystem 512-blocks Used Available Capacity Mounted on /dev/disk0s2 498438976 ...
4
votes
2answers
357 views

SH: How to make vars from one script available in the main script?

I have two scripts that need to run and both require the same variables set the same way. As a result I figured I'd break the setting of the variables out into a separate script. However, I can't seem ...
1
vote
1answer
73 views

Safe way to install .sh script in /usr/local/bin?

I want to include correctly the following script in Ubuntu 16.04. Code #!/bin/sh # http://tex.stackexchange.com/a/20886/13173 # $Id: pdf2eps,v 0.01 2005/10/28 00:55:46 Herbert Voss Exp $ # Convert ...
0
votes
1answer
40 views

Script too slow ? Any particular reason?

I have a script which does hexdump along with pipeline commands and finally I am redirecting it to a file. Now I am logging data from the serial port of my Raspberry Pi. I also call a python ...
1
vote
1answer
17 views

How do I interpolate a text file of 3D coordinates (X,Y,Z) onto a regular grid?

I have a 3D surface in a text file which I need to plot on a regular X/Y grid. However, the values for X and Y are not regularly spaced and are not necessarily in ascending order. I need to regularly ...
19
votes
1answer
1k views

Why is /etc/shadow shortening the password that I've set with the command: useradd -p?

[root@P-dude dude]# useradd -p $6$Ic2PVlwi$2nf.IRWTMy0FHrPza6mh5wjomwbYtIIxnzxPZL7yg8SsvOdbjEpoI0G8uy7AqduYKQOn2R/rnnaalRmfPMy.a0 bwong20 [root@P-dude dude]# cat /etc/shadow | grep bwong20 ...
1
vote
1answer
41 views

Printing the file with number of hardlinks

I can print the number of hardlinks to files in directory by using find . type f -printf "%f %n\n" but this will also print the hardlink not only original files: Example: file1 is an original ...
13
votes
7answers
23k views

How to restart the Python script automatically if it is killed or dies

I am running my Python script in the background in my Ubuntu machine (12.04) like this - nohup python testing.py > test.out & Now, it might be possible that at some stage my above Python ...
0
votes
2answers
520 views

Unix Shell script to delete all traces of itself after execution through crontab

My Question has 2 parts. Help with both parts is greatly appreciated. GIVEN INFO: - Lets assume there are 2 Folders, Folder A and Folder B. - Folder A contains many files. - Folder B contains the ...
17
votes
9answers
14k views

How can I print lines from file backwards (without using “tac”)?

I want to print lines from a file backwards without using tac command. Is there any other solution to do such thing with bash?
4
votes
2answers
278 views

Float operations with bc not precise?

When I'm performing float operations in shell using bc, the result is not the same if I use a regular calculator. Am I doing something wrong? For example, I need to find a volume of a sphere. User ...
1
vote
1answer
48 views

Globbing error due to whitespace

My directory variable POSTMAP="/work/Documents/Projects/untitled\ folder/untitled\ folder/*/*_tsta.bam" My for statement: for file0 in ${POSTMAP}; do ... It seems that the whitespace in ...