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)

0
votes
1answer
36 views

shell sleep until next full minute

To execute a script on the next full minute I want to tell the sleep command to sleep until the next full minute. How can I do this?
0
votes
0answers
17 views

Moving Informatica data(directories) from one unix server to another unix server

Can we migrate directories from one unix server to another unix server, without the need of installation of Informatica softwares on the new unix server? If yes, then will there be any change in the ...
0
votes
4answers
58 views

How to remove line based on Delimeter in perl / Shell?

Can anyone help to remove the line in file based on delimeter(Comma), Incase if line contain less number of columns or Bad records , Need to delete those. Input File: a,b,c,d a,b,d,f c,d a,v,b,h ...
-1
votes
1answer
40 views

Some commands not working in bash script

I'm using Ubuntu 14.04.02 32bit. On doing some shell programming, I found out that running the script through the sh command sometimes cause errors. Is it because the sh command is invoking the ...
-3
votes
2answers
65 views

echo $HOSTNAME result become key to a variable

Property server1=abc,def,ghc server2=xyz,tes,iuy #!/bin/sh echo $server1 abc,def,ghc echo $HOSTNAME server1 with those info above, I want to output the output "abc,def,ghc" in a test variable. ...
1
vote
1answer
39 views

Relation between system calls and shell commands/utilities

In POSIX, Does a system call function often but not always have a command or utility in shell? Is there some rule of thumb about what kinds of system calls have corresponding commands or utilities ...
0
votes
2answers
76 views

Recursively remove files with idx > 10,000

The problem In the current working directory I have several (very many) folders and some of them have lots (like 100,000+) of files inside. My goal is getting just the folder with 10,000+ files and ...
4
votes
1answer
59 views

Source Bash automatically in terminal

How can I automatically source a particular bash script when I open a terminal window by right clicking somewhere and choosing "open in terminal"? For example, every time I open a terminal I need to ...
2
votes
4answers
124 views

How can I find the program I'm hiding in bash

Say I have PATH="home/bob/bin:/usr/bin". I am writing a bash script /home/bob/bin/foo that will do some munging and then call /usr/bin/foo. Of course I want to be able to use this script on ...
4
votes
1answer
53 views

How to make sure the $var variable in expanded in “$varsomething”?

I'm trying to run something like this for n in 1 2 3 4 5 6 7 do run_this_command whatever.$nx$n.in done The files are named as whatever.1x1.in, whatever.2x2.in, ...
-1
votes
0answers
28 views

Can we connect Winscp using power broker?

I am connecting through power broker i.e pbrun command via putty to server. Can someone guide me, How can I connect to the server if I am using WinSCP because authentication will be done only I ...
2
votes
1answer
27 views

passing tmux variable into shell-command in tmux.conf

I'm trying to edit my bottom left status section of tmux. I would like it to show Session: #{session_name} The current maximum length for this string is set at 20 using this setting ...
1
vote
1answer
66 views

Why is this simple bash script throwing an error on if/then/else? [closed]

If I try to run this script: clear echo -n "please enter a value" read num if [ "$num" -eq 8 ] then echo "you entered 8" else echo "the number you entered was not 8" I get the ...
5
votes
7answers
426 views

Turn list into single line with delimiter

I have to take a list (loads) of IP addresses in this format: 134.27.128.0 111.245.48.0 109.21.244.0 and turn them into this format with a pipe in-between (IPs made up) 134.27.128.0 | ...
11
votes
2answers
756 views

What is DISPLAY=:0?

What is DISPLAY=:0 and what does it mean? It isn't a command, is it? (gnome-panel is a command.) DISPLAY=:0 gnome-panel
4
votes
2answers
357 views

while: command not found

I'm trying to do this as an April Fool's prank: make a linux machine display a message in the shell every few seconds. My thought is to achieve this by starting an infinite loop that runs as a ...
1
vote
3answers
135 views

Shell expansion for arguments?

For example: mkdir ~/{1,2,3} Creates directories ~/1, ~/2, and ~/3. It equates to: mkdir ~/1 mkdir ~/2 mrdir ~/3 But, using the same syntax in the case of CMD < argument > : brew {install, ...
-2
votes
1answer
26 views

extracting non hidden files in shell scripting [closed]

In shell scripting while listing a directory need to extract non hidden files need to remove upload, archive and download example : upload archive download simple data final .bash_logout ...
0
votes
2answers
25 views

Dividing up columns and submitting the value as stdin into a seperate program within a script [closed]

I currently have two programs written in C named "remove" and "calculate". When I call ./remove it removes some data from stdin. When I call ./calculate which takes in an argument and also data from ...
1
vote
1answer
38 views

Is it possible to establish a Socket session (between Server and Client) using shell commands ?

From what I read (only the very outline, i do not know C Language) a Socket session is established between a server and a client by calling functions for both of them in a certain order. It starts ...
2
votes
0answers
42 views

List all btrfs filesystems and subvolumes in shell

Is there a convenient way to get information on all btrfs filesystems subvolumes without resorting to C, i.e. in POSIX shell ? /sys/fs/btrfs contains info only on filesystems, nothing on subvolumes, ...
5
votes
5answers
546 views

Getting the pid's of a program line by line

I can find the pid's of my program instances by issuing command like this: pidof avconv Which is giving me results 16616 16283 16279 16198 16175 16035 15073 14049 4922 But how can I output the ...
1
vote
4answers
79 views

find: missing argument to `-exec'

when I'm trying to use this command var1=`sudo -u psoadmin -H -s ssh daill_scp@files.dc1.responsys.net find . -maxdepth 1 -type f -mtime +14 -exec ls -lh \{} \; | awk '{print $5, $9}'|egrep -v ...
3
votes
2answers
52 views

GNU Parallel: Event not found (!~)

About my code: get all .txt files for each file, execute the awk command. All files are processed in parallel if colum 3 does NOT contain "needle", write line to file Result: -bash: !~: event ...
16
votes
4answers
590 views

How can I implement a circular flow of data among interconnected commands?

I know of two types how commands can be connected with each other: by using a Pipe (putting std-output into std-input of the next command). by using a Tee (splice the output into many ...
0
votes
1answer
23 views

Aliasing a command with parameter supplied to another command

Namely: I want to alias tail -f to less +F but let tail with any other parameter supplied work the same way as before.
0
votes
0answers
32 views

echo `“hello terminal” > /dev/terminal` - works for /dev/tty[2-5] but not for /dev/pts/n

I'm trying to get to know the input output systems of unix/linux systems better. Since terminals and devices are implemented to interface as ordinary files, I assumed I could on any desired terminal ...
12
votes
9answers
3k views

Is using “while true” to keep a script alive a good idea?

I'm just jumping into unix from a different world, and wanted to know if while true do /someperlscript.pl done The perl script itself internally has a folder/file watcher that executes when ...
1
vote
1answer
60 views

How to know which platform I am using in lubuntu, ubuntu or kubuntu

I need switch script in between lubuntu, ubuntu, and kubuntu. How can I know which platform the script is running in? Because uname/lsb_release never show different in those 3 releases Lubuntu$ ...
2
votes
1answer
27 views

How do I run two processes and find out when one ends in bash

I was thinking to do something like this: command1 & command2 wait Will this work? I want to proceed when command2 finishes, but command1 can still be running.
0
votes
0answers
60 views

Backup And Restore Shell Script

I have been trying to create a script that backups up a certain directory and then restores the directory. The backup works as it should but when I try run the restore function I get the following ...
1
vote
1answer
37 views

How to interactively remove all directories matching given criteria?

My script below has two problems: The script stops after first matched directory rm -i is not quite interactive What are my incorrect assumptions that make it fail? How can I fix it? ls -1A | ...
2
votes
3answers
177 views

Double square brackets for FreeBSD

I have this code: [[ "$1" =~ [/\\]$ ]] On linux it works just fine, but when I tested it on FreeBSD an error occured : ./projekt2.sh: [[: not found and it .. I there any alternative which would ...
1
vote
2answers
51 views

pipe in shell with redirection

My understanding is that a pipe in shell like a | b redirects b's stdin to a's stdout. However, I tried ls | less < somefile, the behavior is very strange. less shows the output of ls concatenated ...
-1
votes
2answers
25 views

Create new file with spaces from argument BASH [duplicate]

I need to create new file which contains spaces in it. And it is passed through the argument. This code below creates 2 sepate files. Can anyone help me how to create 1 file which will contains space? ...
19
votes
2answers
429 views

Where is “export var=value” not available?

I have picked up -- probably on Usenet in the mid-1990s (!) -- that the construct export var=value is a Bashism, and that the portable expression is var=value export var I have been advocating ...
2
votes
2answers
39 views

Porting Linux date parsing to FreeBSD

I have date in this format: date -d $datum +"%Y-%m-%d" and on Linux it worked OK but in FreeBSD says this: ERROR wrong format usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
1
vote
1answer
53 views

SHELL regular expression ends with backslash

I want to check if the pattern ends with "/" or "\" and before it can be any string. I tried this *\/ * for any string, \ for removing meaning of "/" and / for "/"
0
votes
1answer
49 views

SHELL— Date format validation

How can I check whether the format of date is correct without date command being printed? date -d $datum +"%Y-%m-%d" if [ $? -ne 0 ] ;then echo error exit fi
0
votes
2answers
51 views

What is the variable of $#?

I'm learning introductory Linux and came across something which I did not understand: "The following command has been executed: set 10 20 30 40 50 Enter the value of the variable $#: I understand ...
1
vote
0answers
23 views

How do processes, jobs and session relate to each other ? [duplicate]

Could you deliver an answer in a way that does not require too much special knowledge in advance, yet also deliver some deeper insight to a lesser advanced Linux User ?
0
votes
1answer
49 views

Shell— print only certain lines from output

I need to choose from output only lines where number is bigger than chosen number. For example x=27 and I need to find only lines where the number in first column is bigger than that x. In this ...
1
vote
2answers
33 views

How to run a long running grep, pipe the result into less and put everything into background?

I often find myself in the situation where I need to find a code base for a given symbol like so: find src/galio -not -path './src/stapi-sdk/apilib/* -regextype posix-extended -iregex ...
0
votes
0answers
42 views

Shell splitting line into words without temporary file

yesterday I found out that this creates temporary file. Can anyone help me how to rewrite it so it wouldn't? I am desperate I have tried everything that I know, but it doesn't want to work. And also I ...
3
votes
3answers
110 views

Shell test to find a pattern in a string

I just wanted to ask whether there is any command which would work on common shells (bash, dash, kornshell)? It is supposed to check if the line variable contains any part of the path. if [[ $line =~ ...
1
vote
2answers
120 views

Why doesn't “rm -rf ./” delete anything?

The command rm -rf ./ does not do anything in a directory full of sub directories and files. Why so? Isn't -r supposed to go recursive? To add more confusion, it even prints an error message ...
2
votes
2answers
71 views

Print file contents and delete the printed content* from the file

In Linux, from a bash shell, how can I print the contents of a file and remove the content I just printed content from the file? I have a program writing texts to a file repeatedly. On a Linux shell ...
3
votes
1answer
26 views

Trailing colons and dash's builtin test command

What's the meaning of a trailing colon to dash's builtin test (or [) command? I was surprised when I found that if [ ... ]: ; then .. ; fi works (at all) in dash, but not bash, and it seems to be ...
-3
votes
0answers
33 views

Convert file pattern in Unix

I have a file with content as below 31/01/2014 1234 2234 4567 3321 ...n Need to write a shell script to convert the above file as below: DD_Date='31/01/2014' ...
21
votes
7answers
1k views

`command .*` acts on the parent directory

Someone of our team wanted to recursively change the user permissions on all hidden directories in a users home directory. To do so he executed the following command: cd /home/username chown -R ...