Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

1
vote
2answers
40 views

I cannot understand bash script results

Here is the script: echo '1 2 3 4 5 6' | while read a b c ;do echo result: $c $b $a; done The result is 3 4 5 6 2 1 Can someone explain why?
0
votes
1answer
33 views

Error not found [closed]

I wrote this script to encode / encrypt data from a sql query by changing the names of tables and fields (I played on the ASCII character codes). #! /bin/bash chr() { [ "$1" -lt 256 ] || return 1 ...
1
vote
0answers
23 views

Bash completion - How to get filename completion for suboptions

I have a function which can take main arguments and then sub-arguments. Some of these sub-arguments are filenames. The current completion code I have is as follows. _scm() { local cur prev opts ...
0
votes
0answers
16 views

How to find last x minute internet usage

How can i find out the last X minute download bandwidth in megabyte? i want to use it within a bash script.
0
votes
0answers
30 views

The program called by the init.d works by itself, but not when the init.d itself runs

I currently have two programs, my_sql_auto_update.sh and my_sql_auto_update_initd.sh, the latter is the init.d script located at ~/etc/init.d/ which [should] run the my_sql_auto_update.sh. The ...
1
vote
1answer
25 views

How to display a Image on a remote linux machine through ssh

I have two computers, one running windows(WIN7) and the other running linux(SUSe). I'm wondering if there is a way to ssh(Putty) into the linux machine and run a command to have a image display on the ...
3
votes
4answers
462 views

Is is possible to modify a file in a read only directory? [duplicate]

I have already read: Is there a way to modify a file in-place? I am curious if there is a way to modify a file in place using a command that will not create temporary files. Let's say I create a ...
2
votes
1answer
33 views

How can I popd to a specific directory?

I have used pushd to move about to various directories and now If I run dirs -v I get: 0 ~/Desktop 1 /etc 2 /var/log 3 ~/Downloads 4 /tmp How can I popd to a specific directory in the ...
1
vote
3answers
90 views

Bash long string, no word splitting?

I want to tidy up some script with long commands, so that for example: { somecheck || somecomand "reallyreallyreallyreallyreallyreallylongstring" } &> /dev/null & becomes something like: ...
0
votes
1answer
31 views

How can I get this array of numbers sorted? [closed]

I have an array called colNums that looks like this: 1 5 4 2 2 7 When I print the array with echo "$colNums" it prints like that. I want this list sorted. ...
2
votes
2answers
55 views

Why am I getting “invalid max count” from grep in an alias?

So the idea is to create an alias that will search my alias's for me. I have quite a few. dude@gnarleybox:~$ grep alg .bash_aliases.sh alias alg='alias | grep ' dude@gnarleybox:~$ alias | grep alg ...
1
vote
0answers
23 views

What Does the Output of “--help” Mean? [duplicate]

When using the --help option of a terminal program, a lot of output is produced. It usually starts with Usage: and then a bunch of things and brackets and parentheses. My question is, what doe the ...
1
vote
2answers
55 views

How do I make a BASH loop

I'm very new to bash and Linux and I was wondering how I could make a bash loop so that when it runs, it will ask you how many times to run, and it will run that many times. I did it in LUA but I ...
2
votes
3answers
70 views

bash: error handling on find -exec

I was using this little script to find malformed images: find -name '*.jpg' -exec identify -format "%f\n" {} \; 2>errors.txt It worked well enough, but now I need to modify it slightly. Instead ...
0
votes
1answer
20 views

How to include single quotes in bash folder expansion?

Edited* I have the following definitions in my bash script: DATE_SUFIX=$(date +%F_%H-%M-%S) NAME="MyBackup_" FILE_NAME=$NAME$DATE_SUFIX TMP_DIR="/tmp/" TMP_BKP=$TMP_DIR$NOME_ARQ"/" TAR_CMD="tar czPf ...
4
votes
1answer
52 views

What can cause an item to be deleted from my bash history?

About once a day, I'll run into an issue when I search for a history item in bash. Manipulating that item sometimes deletes the history entry, and sometimes doesn't. Here is one case of this ...
0
votes
0answers
41 views

Counting program fails in arithmetic test

having a little trouble with this rather basic script. This script works on Bash in my macbook pro, but not on my Linux Mint desktop, which also uses bash. I can't figure out what's wrong with it, ...
2
votes
1answer
45 views

Bash - Command substitution adds single quotes

I have a problem with bash behavior while evaluating grave accents. I want to run find with optional -name: find -name "*.log" works fine, but when i want to get the -name part from nested script ...
0
votes
1answer
45 views

Print file name,Modified Date and Size with Header

How do I print file size, file name and modified date with header.Till now I have come up with: find . -regex '.*\.csv' -execdir stat --printf '%n,%y,%s' {} \; How to add header and do not print ...
1
vote
1answer
54 views

Running some parts of a script as an unprivileged user with shell environment

I am creating an instance configuration script that sets up a machine. I am running the script via sudo i.e. sudo run.sh. Most of the steps require root access but some of the script's steps do no ...
1
vote
2answers
58 views

Using command substitution

The shell variable number contains 1 1 1 1 1 separated by tabs. I want it to contain only the first 1. I'm trying number= $(echo "$number"| cut -f 3 ) and I get the error "1: ...
4
votes
2answers
71 views

Expand wild cards in command before executing it

Suppose I want to type something like this: rm build/* tmp/* I am about to run it but I want to expand the wildcards before executing so I can verify what is about to happen. How can I do this? ...
-2
votes
1answer
88 views

Sqlplus: Command not found

I have two virtual machines ubuntu, one is a server when I installed oracle 11g express, and the other is a simple client. My goal is to run an sql query remotely from the client machine. So I ...
0
votes
2answers
39 views

How do I run find, maxdepth and other commands on lcd while using ftp?

I have got the command working locally using normal commands. I now need it to run while using ftp. I understand I need to use '!' And instead of copy I will need to use put so it works on the lcd, ...
0
votes
1answer
31 views

Copy tree directory from specific point

I am now sure how to word this, but: I am copying all the newest .zip files each recursive sub directory inside this original folder: "/Users/Stu/Documents/Hoffi Work/FTP Backup Shell ...
1
vote
1answer
77 views

Sed command that would ignore any commented match

I'm trying to create a sed command using regex in order to substitute something in a text file only if it is not commented but I'm running into some troubles due to my almost non-existent knowledge of ...
0
votes
0answers
21 views

Export data from Oracle to Excel [closed]

I would like to export data from oracle database on daily basis to excel sheet. I would also like to add a date condition in shell script, with which I can have data for different dates in different ...
0
votes
0answers
11 views

What shell extension recommends packages if command is not found and how to update it? [duplicate]

I know this question might sound a little strange but i really don't know how to describe it better. On my Debian system I have a shell extension for bash that, whenever I enter an unknown command, ...
4
votes
2answers
96 views

Safely exiting while loops in bash

Say I have a bash script that does: while : do foo done I would like to be able to run this script from the console and be able to exit it at an arbitrary time as long as it happens in between ...
2
votes
3answers
169 views

AWK & Bash: Checking that a User's Home is Owned by the User

I'm trying to cycle through /etc/passwd with a single-line command in order to find those users who have a home directory which is not owned by the user, but I'm VERY new to bash programming, and I ...
0
votes
0answers
22 views

Is there a way to add a timestamp to the logs for qsub job?

I'm submitting jobs on a cluster via qsub but the error/output logs don't have a timestamp, making debugging more difficult. Is there a way to add timestamps to the logs in the bash script? Appreciate ...
1
vote
1answer
65 views

Running every command through another

I'm setting up a system in which any external command that does something with real effect must be crypthographically signed before before the system will execute them. The restrictions are in place ...
2
votes
4answers
96 views

How to make diff command ignore certain lines of second file(bash)?

For example: file1.txt: I need to buy apples. I need to run the laundry. I need to wash the dog. I need to get the car detailed. file2.txt I need to buy apples. I need to run the laundry. I need ...
0
votes
3answers
45 views

copy the contents of a variable in a text file

I know this is a stupid question but I want to know how I can put the contents of a variable in a text file. This variable is a string that I want the code with the base64 command.But this command ...
0
votes
0answers
21 views

Linux, dev/tcp validation and kill the process with timeout

I have this part of code, I need to validate if the connection was ok or not, AND, if the process is running more than 3 seconds, it will be killed. But, I dont know how to keep the value of the ...
0
votes
5answers
113 views

Read File word by word

My problem is to read a text file word by word and recovers every word in a variable. I tried to do: while read ligne; do { for ( i=1; i<= length ($ligne); i++); do { var=$(awk '{print $i}' ...
2
votes
3answers
149 views

KSH/BASH Maximum size of an Array

What is the maximum size of array for ksh and bash scripting ? Example: Suppose I have an array of 10 elements than what will be maximum number of string count that a particular index of an array can ...
0
votes
0answers
13 views

I have used --data-urlencode with continue command character “\” to continue command on next line but can't get output.

curl -k -u user:password -d "output_mode=csv" --data-urlencode search='search source=*/**/94.0*M2E-CSI* \ "Caused by" \ | table host, source' -d 'max_count=1' -d 'earliest_time=-32h' -d ...
0
votes
2answers
8 views

VNC/SSH: How to execute a command after logging in?

I'm looking for a way to create a VNC console user that executes the command screen or bash immediately after logging in so they get their own restricted shell for executing commands etc. Screen/bash ...
-4
votes
2answers
18 views

How do i might read and write files with bash, bash script? [closed]

sombody help me to get the command orread and write files with bash script, i know via cat, and echo >>, but i want to find lines and replace especific characters, not usses with new lines
1
vote
2answers
24 views

stdout to log, stderr to log and console

I'm trying to send all output to a log, with stderr also displaying in the console. ..with the log entries in order and some method to send comments to the log+console (same as stderr). exec ...
4
votes
1answer
46 views

How can I launch a command, wait 2 seconds and return the output without killing the command?

I'm trying to launch a command from php with shell_exec which calls a bash script that launches a program that stays running, but sometimes this program throws an error and exit, what I need is a way ...
0
votes
1answer
26 views

Using egrep in Bash

I'm taking a UNIX course atm, and I've got a newb question. In the following code, I'm getting an error and I'm not sure why: [name@unix ~]$cat test123 123 456 789 1011 1213 [name@unix ~]$egrep ...
1
vote
1answer
35 views

Displaying “No Results” When AWK Command has no output

I have the following code, thank-you to the people who helped me here awk -F: '{if(system( "[ -d " $6 " ]") == 1) {print "The directory " $6 " does not exist for user " $1 }}' /etc/passwd However, ...
8
votes
4answers
254 views

How do you check if a file exists within awk? [-d 'filename'] failing

I'm trying to generate a list of users who have a home directory set which does not exist. It seems I should be able to do this with awk, but something is wrong with my syntax. It keeps telling me ...
2
votes
0answers
58 views

Bash regular expression comparison fail for hex byte \x01

Bash regular expression fails to compare correctly for $'\x01' when End-Of-String char $ is used. All other byte values (seem to) compare correctly. Using GNU bash 4.1.5(1). Is this a bug, or is ...
0
votes
2answers
29 views

recording total runtime in bash script

I have the following script. When it runs it prints the Start and end Times to the file 'result.txt'. However, I also want to record the total runtime (end-start), but where I am doing echo runtine ...
-1
votes
2answers
38 views

Linux Bash Scripting Issue with Wildcard

I'm having issues with what I imagine should be a simple bash command I'm basically just trying to loop through a bunch of files and get there names `ls ./*.sql` # list all files ...
0
votes
0answers
22 views

KSH/BASH Comparsion b/w Two Array and then logical OR operation at other function (GNU bash 4.2 version)

I am new to unix and learning it basics. I wanted to compare same index of two different arrays and on the basis of comparision I wanted to put a data to other array. First I tried to use it ...
1
vote
1answer
38 views

Figuring out the dates for a given week

With date -d @[some_timestamp] +"%U" the end result is a number between 0-53, which represents the week in which the [some_timestamp] is located. So if I have an arbitrary timestamp ie 1426815663, the ...