Tagged Questions

A shell is software that lets users interact with the operating system, usually by typing at a command-line.

learn more… | top users | synonyms

0
votes
2answers
18 views

How to store results of multiple sql queries in shell variables in Bash?

I need to store in array the results retrieved from the database. So far this is basically what I'm trying with no success. Myarray=$(echo "SELECT A, B, C FROM table_a" | mysql database -u $user ...
0
votes
2answers
14 views

Output redirection at the beginning of line

I'm used to specify output redirection on the end of the line like: echo blah > output.txt Both in Windows and *nix. Recently I'm seeing more and more examples that redirect at the beginning of ...
1
vote
1answer
14 views

Yum batch install package cause 100% CPU load?

I need to install a list of package as follow; so I made a small script automate it: yum -y install libstdc++.i686 yum -y install libibcm.x86_64 yum -y install librdmacm.x86_64 yum -y install ...
1
vote
1answer
16 views

Is there an event fired right after a command finishes executing?

In Bash, after you type in a command (e.g., ls), it will execute the command, which will write its standard output (if not redirected) to the terminal (in our example, the content of the current ...
0
votes
0answers
12 views

Parsing XML log in shell

I have to parse a very large log file and I want to use the command grep (or any other tool). I am currently using PuTTy. I want to search for each log line for a specific string (let's call it AWB) ...
2
votes
5answers
200 views

UNIX how to resume process using ID?

I have a problem to resume process. I tried to get process to foreground using jobs, it works, but if i close shell and start it again. In this case i haven't my process in jobs list. I know just ...
0
votes
0answers
10 views

adb shell dumsys cpuinfo

DUMP OF SERVICE cpuinfo: Load: 9.39 / 19.22 / 14.77 CPU usage from 13119ms to 6195ms ago: **25%** 5442/com.gameloft.android.ANMP.GloftA8CN: **17% user + 8.3% kernel** / faults: 39 minor **21%** ...
0
votes
0answers
20 views

Shell script force stop without waiting for the exit code

I have written a shell script checklick.sh on my CentOS box with the following content: #!/bin/sh # # description: check link through rtmpdump # . /etc/rc.d/init.d/functions ...
3
votes
1answer
28 views

How can I check if timezone has changed in a bash script?

I have a shell script that runs via crontab, but the commands in it are timezone dependent (they refresh a table in database everyday. If the script runs during the time of a DST change, it will ...
0
votes
1answer
20 views

Damaged preference file in /bin/sh

Today in Drive Genius 3, I ran the “Verify Preferences” function in Repair. It yielded this strange result: /bin/sh: xargs: command not found The only option Drive Genius gives is to remove the ...
0
votes
0answers
5 views

Shell unbuffering for CygWin: is it possible?

I have tested on CygWin doing "ls -R" with a large directory and sending the output to a Test.txt file, so the process takes about 30 seconds to complete; the file is created, but it is empty; it will ...
1
vote
2answers
24 views

Status line in linux shell

I use Windows and Putty in order to remotely connect (ssh) to some linux servers. I have set my hardstatus in my .screenrc file so that I can monitor some useful information. But this works only when ...
1
vote
1answer
17 views

Search for string and read the next line

I need to write a shell program that installs some packages. The program will run on Linux (obviously some commands will not work, for example, on Arch-based distros). So, I've got this file called ...
0
votes
1answer
21 views

processing sequential and parallel jobs in bash script

I understand that in bash programming, comamnd1;command2;command3 will run them sequentially while command1&&command2&&command3 will run them in parallel. However what happens when I ...
0
votes
0answers
15 views

How to revoke myself rights to write files outside current directory?

I want to make sure commands that I run from my shell cannot damage my files above starting directory. For example, this command should fail: cd ~/ && rm -rf *. Supporting links, mount points ...
1
vote
1answer
21 views

Indent execution results in zshell

I'd like to customize my zshell so that the prompt is butted up against the left border like normal. I'd also like to have all execution results indent by perhaps 2 spaces. Is there a way to indent ...
2
votes
2answers
26 views

Is there a man page for PROMPT in zsh?

I know how to look up commands with the man command. When looking at other people's .zshrc files, I see what I think are builtin variables (PROMPT, RPROMPT, etc.). Where might I learn more about ...
1
vote
5answers
80 views

How can I rename/move a file by simply “editing” its path in a shell?

Consider the problem that you want to rename a file called some/path/File With A Long Name.txt into some/path/File with a very long name.txt. To me, this was always one of the few situations, where ...
2
votes
1answer
33 views

In bash 4.3.27 “su” ignores user variables when combining “-” with “-c command”?

Since forever we used to launch user scripts from a different user crontab like this: 00 12 * * 1 su - user2 -c "/home/user2/myscript.sh" By doing this, the script is launched after the interactive ...
2
votes
1answer
21 views

How to show a caret-C in canceled command line in zsh, like bash does?

When I'm in the middle of entering a line to my shell of choice, and change my mind, I can quickly throw C-c and start afresh. Under bash it looks like this: user@machine:~$ rm everything^C ...
1
vote
1answer
12 views

ZSH custom widget not working as I think it should

I'm trying to define a function so that I can launch Midnight Commander by pressing Alt-, but the function just doesn't work. I found and modified a function on another site and modified it so: ...
0
votes
0answers
28 views

Script to automate copy files with a pattern over network

I am trying to automate some tasks... I have to do some development work on one machine and other parts on another machine, with communication through a network share. I would like to copy certain ...
16
votes
3answers
857 views

Prevent currently running linux task to be killed after logout from SSH

I have a computational task running for a few days on a linux server via SSH connection. It is not on the background, so the SSH connection is under hold of the task. I want to restart the local ...
0
votes
0answers
19 views

Running terminal command on all files in folder? [duplicate]

I need to convert 500+ .xlsx files to .txt (or .csv). To do this I found this. It works well if I write the command like this: xlsx2csv fileA.xlsx fileA.txt I have however been unable to run the ...
0
votes
1answer
21 views

Tar not preserving permissions on extract

I'm backing up a users folder as root using tar tar -czf /mnt/disk/cloud.tar.gz -C /home/cloud/ . In /mnt/disk I do a test tar ztvf cloud.tar.gz and it shows -rw-r--r-- cloud/cloud 14 ...
0
votes
2answers
31 views

ascii value in bash/awk

i have a doubt, i know that with this command, it prints the value of a character based on the Ascii table: printf "%d\n" "'a" ##prints 97 But i wonder how can i make my programm show me the ascii ...
0
votes
1answer
25 views

Where do the variables of a new BASH shell come from?

I am puzzled as about how environment variables work. From what I am aware, for a new process to have some environment variables, its parent must have issued export. But what about all the variables ...
0
votes
2answers
58 views

How to check if busybox has a command?

In my case, I want to see if busybox has "md5sum" builtin. I am currently doing this: $ echo | busybox md5sum &>/dev/null && echo yes || echo no I have not been able to find any ...
2
votes
2answers
47 views

Warning for rm -r command

I want rm to prompt me when recursively deleting a directory, as in: $ rm -r <dir> Do you want to remove the dir(Y/N)? Is there an argument I can pass to rm that will do this?
0
votes
2answers
85 views

Bash script that calls a program with some asterisks in arguments

I’ve spent last hour or so trying to write a pretty simple bash script and I never felt so dumb. So I have a list of strings (which are package selector specifications for a package manager, if that ...
0
votes
1answer
28 views

Passing different set of arguments to the different commands in a linux bash script

I am writing a bash script foo.sh that runs too commands bar with first input argument, and baz with the second argument: #! /bin/bash bar "$1" baz "$2" Now I want to make foo.sh more flexible, ...
1
vote
5answers
88 views

How to copy hidden (starting with a dot) files and subdirectories in linux?

How to copy hidden files and hidden subdirectories (the ones starting with a dot) in folder A to folder B? For example if I have this structure: A/a A/b A/.a A/.b/ A/.b/somefile A/.b/.c I would ...
0
votes
0answers
12 views

OpenWrt Script (Inifinite Loop) Stops sending data over Serial Port

I have a TP Link Router TL-MR3020 flashed with the latest Attitude Adjustment. It is connected to an Arduino Uno via the usb port (usb cable into the arduino's type b connector). I have the following ...
3
votes
1answer
16 views

In bash, declare an alias that depends on current variable content

I would like to declare an alias in my .bash_profile that will use the content of a variable when the alias is used and not when it is declared. Ex: alias goSomeWhere="cd $BASE/somewhere" When ...
0
votes
1answer
30 views

modify shell command in Ubuntu 14.04

I had installed Ubuntu 14.04 on virtualbox, I need to be able to read source code of shell commands, and modify any command? any help please? where i can find the shell commands? in which directory?
0
votes
1answer
22 views

Kill browser tabs with Bash from younger to older

Hello i want to kill tabs from a browser(ex. chromium) by order from youngest to oldest. I used pkill -f -n -9 chromium but i want to use it in a while iteration with comparison to pkill's return ...
2
votes
1answer
59 views

What is the difference between “elif” and “else if” in shell scripting?

I am very new to shell scripting. When I look at some code, written for ksh (#!/bin/ksh) I see there is else if as well as elif used in one script. So, what is the difference between else if and ...
1
vote
2answers
32 views

Alter output of every command

I'd like to know if there's any way of altering output of every command I execute in terminal. The purpose is to make the output formated for my markdown howto's. E.g. ls -la .*z #>-rw-r--r-- 1 ...
1
vote
1answer
47 views

echo “something” > file not working when sh script is being executed by remote PHP server

I've got a web-server with my hardcoded webpanel for Source server management and I've got my VPS on CentOS which doesn't really want to execute sh script when asked from remote server. Web-server ...
1
vote
1answer
33 views

Good way to bookmark/navigate relative directory paths?

I work on a linux system with bash 4.x where I frequently find myself navigating different copies of very deep (and large) file directory structures. However, in reality I only need to access a ...
1
vote
2answers
187 views

Why is “source <(cmd)” working but not “$(cmd)”

I want to have a script to call with params which adds some aliases to my current shell. The aliases have to be builded in respect to the calling parameters and the current directory from where I ...
1
vote
1answer
32 views

Split very long line of words into separate lines of max length

I have a script that outputs a list of packages on a single long line separated by spaces. The information included in this line shall be inserted into a text file which is later presented to a user. ...
2
votes
1answer
52 views

Percent sign (%) in front of shell command

I just pasted a bunch of code into my shell, but forgot to remove the leading % before running the command. It appears to have done nothing. Why does this do nothing in my shell (zsh)? > % echo ...
0
votes
1answer
47 views

Linux find files in subdirectories by extension (.txz) then move them to specified directory using regular expressions

I have mirrored a directory from a server with a large number of sub directories, each of which contain a .txz package and the usual .txt and descriptor files. What I would like to do is the ...
66
votes
2answers
7k views

Is “ps -u” Really a Bad Syntax?

IMHO ps -u shows a very useful output, much better than ps -u $USER: $ ps -u Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ USER PID %CPU %MEM VSZ RSS TTY ...
0
votes
1answer
26 views

output of sudo -l confusing me

(habdbsync) NOPASSWD: ALL, (habdbsync) !/bin/sh, !/bin/ksh, !/bin/csh, !/bin/tcsh, !/bin/zsh, !/bin/bash, (habdbsync) !/bin/su, (habdbsync) !/usr/bin/ssh, !/usr/bin/scp, !/usr/bin/slogin (root) ...
1
vote
1answer
95 views

How to justify and center text in bash?

Newbie here. I'm looking for bash script to center and justify text. My script only works with one line of text. How would you improve it? #!/bin/bash COLS=$(tput cols) while true; do clear ...
2
votes
2answers
193 views

How to take control back on a separate process in Linux shell?

I just set up a Minecraft server on my VPS for my brother and I ran it with a bash script : sh ./server.sh& This way, the server is running and I can still work on the same command line with ...
1
vote
0answers
31 views

UEFI shell mode with no colon key

I have a newly built PC with a UEFI-enabled motherboard and I'm having trouble getting my DVD drive to boot into UEFI mode so I opted to boot into UEFI Shell to manually start the DVD in UEFI mode. ...
1
vote
0answers
63 views

Unexpected Bash glob completion uses first match even if ambiguous

If I have the following files in a directory: $ ls a-file-1 b-file-2 something-else And I type $ cat *file*<TAB> The line unexpectedly updates to $ cat a-file-1 | (pipe denotes cursor) ...