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)

3
votes
0answers
27 views

Why isn't apt-cache policy output piped?

Cannot get why $ apt-cache policy foo N: Unable to locate package foo but $ apt-cache policy foo 2>&1 | grep . is empty. Where in the latter call am I doing the wrong assumption? The ...
0
votes
0answers
18 views

Help in manipulating a test file

I have a file look like aaa/bbb/ccc.bbb aaa/bbb/ddd.bbb aaa/eee/fff.eee aaa/eee/ggg.eee I would like to skip lines ending similarly(.bbb & .bbb) and add a string only after all occurrence for ...
6
votes
5answers
363 views

Storing bash scripts

What is the good common practice to store shell scripts? (bash, sh, ...) For now, I have a few bash and sh scripts in my $HOME directory and I invoke them with $ bash $HOME/script1.bash arg1, arg2, ...
1
vote
2answers
26 views

Replace screen process from within screen

I have configured my shell to exec screen when it starts, unless it's already running within a screen session. So in a TTY, the process tree will look like something like this: ...
0
votes
1answer
22 views

Syntax Error while running command from another hosts [duplicate]

I run a command to fetch server uptime as below [root@localhosts ~]# printf "`uname -n` `uptime| awk -F " " {'print $3,$4'}`\n" localhosts 75 days, Now when I run same command from another ...
0
votes
1answer
23 views

How does this text reformatting happen with ack?

If I do a plain ack for a string, I get a line with the filename, and then the line numbers and the matching lines, like so: $> ack function mymodule.file 8: function myfunction1() { 16: public ...
-6
votes
0answers
28 views

Shell script that facilitate exel everyday work [on hold]

how to create a script that open an exel page and take specific data f eg: 2 3d 2014 the porcentage of people get inscripted in my center...how much they all payed...taking into consideration exel ...
0
votes
1answer
28 views

Shell Script Help - Automatically assign users to group

Recently, I have just started to learn linux and I am currently trying to make a shell script that can automate the task of creating user accounts, assigning them passwords and then assigning them to ...
0
votes
1answer
37 views

Strange output when echoing variable from a different user

$ sudo su - user1 -c 'echo $DOMAIN_HOME' /app/user1/DOMAINHOME This looks fine, right? However, let's dig a little deeper: $ sudo su - user1 -c 'echo $DOMAIN_HOME' | tee test.out $less test.out ...
-2
votes
0answers
36 views

Writing a shell script into startup file .profile [on hold]

I need help printing any one of the following messages using echo statements as soon as I logon to the system: "Good Morning", "Good Afternoon", "Good Evening" according to the system time. I could ...
1
vote
1answer
58 views

how to run script with a clean login shell

I am connected to remote machine Linux RH6 directly via ssh (key imported on server), when I execute a shell script with arguments for restarting the java service, I have a strange issue with ulimit: ...
3
votes
4answers
124 views

How to maintain a specific number of processes running?

I'm trying to write a shell script for converting a lot of .wav files to .mp3. I use the "find" command to find them, then the "lame" command to convert. I can use a simple for loop for this but I ...
0
votes
3answers
68 views

Remove lines in a shell script

I have this file: # more file.txt 2c2 lns-ld-wall-01-t2 old:261,260 4c4 Prive_ORANGE old:258,259 I need to remove all lines like this one 2c2 and this one 4c4. How can I do in a shell script?
0
votes
1answer
22 views

Run Application without Holding up terminal [duplicate]

If i wanted to run an application from the terminal (linux, ubuntu), how do I do so so that the terminal is still usable or that so if I close the terminal, the application still runs.
0
votes
1answer
50 views

How do I center-align a column in UNIX?

I’m trying to center-align a column using the command column. The output should look like this: temperatures 50 12 89 63 How can I do this?
2
votes
5answers
64 views

`xargs` with spaces in filenames

I'm trying to list only non-image files, searching only in the most recent 500 files. So I run ls -t | head -500 | file | grep -v 'image' which isn't right: it displays a help message. Changing it ...
1
vote
1answer
33 views

Host linux distro without GUI?

I saw this video on Youtube: Run Kali Linux on Android The phone uses the app: Linux deploy, which uses the phone to host the distro, but there's is no GUI. The only way to connect to Kali, is by ...
1
vote
1answer
25 views

process id and command

I want to write the process id and command of all processes with some name and from some user (for example root and init). What should I do? ps -f -u root -C init or ps -f -U root -C init ...
2
votes
1answer
33 views

Shell Scripting: Deleting or moving files from one directory that match filenames from another directory

I have a very specific and odd problem to solve. I'm working as a research assistant and I've been producing a ton of figures. In one directory, I dump .pngs to view casually (limited space here) and ...
0
votes
1answer
50 views

How to avoid executing a command if a process doesn't exist

In a korn shell script, I am running expdp. I have made the script to where it can be reusable so if a later process fails, I can run it again without running the already completed steps. I am running ...
2
votes
2answers
33 views

universal help/man command: help builtin partial matches

I found a nice little script which iterates through a couple of manuals for a specific command. As a last resort, it will Google it and open a browser window. Source here: ...
6
votes
3answers
126 views

Get files with a name containing a date value less than or equal to a given input date

One of my folders contains files in the following format: 3_20150412104422154033.txt 3_2015041211022775012.txt 3_20150412160410171639.txt 3_20150412160815638933.txt 3_20150413161046573097.txt ...
-2
votes
2answers
61 views

Parsing a flat file using shell script

I have a file like in following format User:blala Pass:blala IP:***.***.**.** I tried with IFS but it is not working input="/path/to/your/input/file.cvs" while IFS=',' read -r f1 f2 f3 f4 f5 f6 ...
0
votes
2answers
37 views

How to grep from command line for theses multiple strings?

I need to run a command to grep one of these strings from command line as web host disabled account to run website from browser until virus files are removed and I managed to collect few strings that ...
-2
votes
0answers
22 views

How to take input from a file using a C program? [migrated]

I have to take input from a file and convert the number from kelvin to fahrenheit(vice versa), using a "C" program. Requirements: The conversion and numeric outputs must take place in the ...
1
vote
1answer
41 views

Executing commands consecutively based on log output

I have a written a script to start my services one by one. After each service finish, it should execute the next command, and wait until first command executes for that I have given this command: ...
5
votes
2answers
102 views
+50

Identify alias for the command typed

Is there any shell/shellscript which identifies that there is already an alias for the command I have typed on the command line. Eg On shell I type git checkout master Shell prints "You can use ...
1
vote
1answer
35 views

Script executes differently if run from udev

I'm having an issue with a script that seems really weird; it appears to stop executing prematurely when run from udev, but not when I run it manually from the command line. I've tried troubleshooting ...
0
votes
3answers
47 views

How can I format output of shell command

I combine top and pidof command: top -p $(pidof <process_name>) If pidof <process_name> return one id top command works. But if pidof <process_name> more than one ids top command ...
0
votes
1answer
57 views

“bash: reboot: command not found” can't found a solution [closed]

As root or when using sudo when I do reboot or shutdown, the shell replies: bash: reboot: command not found I don't understand where the problem is and what's the resolution ! This is my $PATH ...
0
votes
1answer
24 views

ksh: Not importing prompt settings from /etc/profile

I am using SUSE Linux Enterprise Server 11 SP3 and I am facing an issue related with a user using ksh. I have created a user as follows: ...
1
vote
1answer
33 views

How do I get the language for messages?

Is there a single command I can use to get the language to use for messages or do I have to check LC_MESSAGES, LC_ALL, LANG etc. in some specific order?
2
votes
1answer
48 views

Debian: How to get the current loaded kernel package name?

With the following command, I can list all the installed kernel package: $ dpkg -l | grep linux-image With the following command, I get for instance the version of the current kernel used: $ uname ...
1
vote
1answer
42 views

How can I prepending a character for every output of a command?

I'm running commands which I want to specifically group them by every command, as shown in the example below. Tried printing with echo -e '| $line' but it only affects commands that output the text ...
2
votes
2answers
37 views

Does zsh expansion work differently in non-interactive scripts?

I'm currently working on a pretty simple zsh script. What I often do is something like: mv */*.{a,b} . When I run that within a zsh script, it seems to expand differently and fail while it works in ...
1
vote
3answers
61 views

Rename files (delete some characters that are not always the same)

I have some files named like this : DA1_ATGCATG_L001_R1.fastq.gz Oeu43_TCATGAC_L004_R2.fastq.gz I want to delete the part after the first "_" but keep the end of the names from "_R" to obtain this ...
2
votes
3answers
113 views

tar unix not changing directory

I am executing a tar command to compress files which are present in another directory. I executed following command: tar -czf /backupmnt/abc.tar.gz -C /backupmnt/statusService/ * I want to create ...
3
votes
4answers
107 views

Shell usage of “:-” and advantage

I found this line in a korn shell script: var=${var:-/temp} I am able to figure it out what it is doing $ var=/data $ var=${var:-/temp} $ echo $var /data $ var= $ echo $var $ var=${var:-/temp} $ ...
3
votes
1answer
33 views

using shortcuts to move in bash command line [duplicate]

When I use Ctrl+Left_arrow or Ctrl+Right_arrow in bash, I move backward a "word" and forward a "word" respectively. I belive, this is defined in /etc/inputrc # mappings for Ctrl-left-arrow and ...
0
votes
1answer
18 views

start process from ssh and be able to close connection [duplicate]

I'm connecting to my RaspberryPi with Raspbian installed via ssh and my problem is, that I can't let the RasPi do things (installing software, make calculations) while my Computer is shut down, since ...
1
vote
1answer
38 views

How to create dynamic process substitution based on the input (multiple FIFOs)?

I'm trying to create multiple process substitutions based on the output from the other command, however I'm not sure how I can achieve that. As sample scenario, I've given list of files: touch a.txt ...
2
votes
2answers
76 views

Where does the TERM environment variable default get set?

When I open a terminal window with the GNOME Terminal emulator in the desktop GUI the shell TERM environment variable defaults to the value xterm. If I use CTL+ALT+F1 to switch to a console TTY ...
3
votes
2answers
270 views

Why I should avoid loops in shells? [duplicate]

The following link recommends against using loops in shells. bash variables in for loop range Why is this? Here is an example loop I just happened to be looking at when I came across that answer: ...
1
vote
1answer
35 views

Python now thinks arguments are files: Broken emerge, pip, livestreamer and most tools using Python

For these commands (in both bash and fish): sudo emerge eix emerge eix I get this error: usage: emerge [-h] [--version] [input [input ...]] emerge: error: argument input: can't open 'eix': [Errno ...
0
votes
1answer
29 views

Multiple input files and output files in awk

I have a folder full of text files named 000.txt to 181.txt. How can I process all of them with the same awk script (program.awk) and send them to their respective output files (output000.txt - ...
1
vote
1answer
29 views

Unzip specific files from multiple zip files

I'm new to Unix and am trying to extract specific pattern filename from the multiple zip files. I'm using find to find the zip files, and then trying to extract files having the filename CTL in the ...
6
votes
2answers
118 views

Exclude one directory in `ls` matching pattern

I'm trying to ls dirs that have .png files inside (no need for recursiveness, though it would be extra useful), exept one. Exlude one directory i.e. ls */*.png works fine. ls (^one)*/*.png ...
0
votes
1answer
43 views

command “find … -exec mv …” created a file with strange content

I wanted to move binary files from folder /myhome/sourcedir to /myhome/targetdir. I used a command find /myhome/sourcedir -type f -cmin +3 -exec mv '{}' /myhome/targetdir ';' Folder /myhome/sourcedir ...
2
votes
2answers
30 views

Git alias multi-commands with ; and &&

I want to have an alias that execute a command and then whether it fails or no it execute other commands that depends on the success of each other. So I have something like that in .gitconfig ...
0
votes
0answers
44 views

Shell intervals using awk

I have a file a 10:10 10:30 b 12:15 13:15 c 16:54 17:54 and I need to enter interval for example 10:15 so my output should be a 10:10 10:30 How I need to do that using awk?