bash4 Questions
7
Solved
9
Solved
How can I write multi-lines in a file called myconfig.conf using BASH?
#!/bin/bash
kernel="2.6.39";
distro="xyz";
echo <<< EOL
line 1, ${kernel}
line 2,
line 3, ${distro}
line 4
line ......
4
Solved
I'm relatively new to bash programming and i am currently creating a simple calculator.
It needs to use floating point numbers and check they are so.
I have a checkNumbers function:
function che...
Cockcrow asked 9/12, 2012 at 19:11
5
Solved
Based on an associative array in a Bash script, I need to iterate over it to get the key and value.
#!/bin/bash
declare -A array
array[foo]=bar
array[bar]=foo
I actually don't understand how to...
Voyeurism asked 24/6, 2010 at 18:7
4
Solved
I'm trying to write a not found handle in Bash that does the following:
If $1 exists and it's a directory, cd into it.
If $1 exists inside a user defined directory $DEV_DIR, `cd into it.
If the p...
1
Solved
This is my $a output:
[root@node1 ~]# echo "${a}"
/dev/vdc1 /gfs1
/dev/vdd1 /elastic
mfsmount /usr/local/flytxt
I gotta store these in an associative array fsmounts with first column as ke...
Enchorial asked 7/2, 2019 at 6:9
1
Solved
In bash 4 (and above), to capitalize the first letter of a string stored in variable L1, I can do the following:
L1=en
Ll1=${L1^}
echo $Ll1
This prints En.
I'm trying to do something similar wi...
Sloatman asked 1/5, 2018 at 9:40
1
Solved
I have IDs in the first column of data.csv with headers.
I want to skip the header and store column 1 values in the variable ids as 102 103 104 ....
Pseudocode in the line ids.append($col1) where...
3
How can I save the error output when running my script to a file?
I have my code bellow, but the code does not track error and save the error to test.log14.
Can somebody give me a hint on what coul...
2
Solved
In a server with bash version 3 I do this:
bash3$ e="tar xfz"; [[ "$e" =~ "^tar" ]] && echo 0 || echo 1
0
But when I execute the same command in bash version 4
bash4$ e="tar xfz"; [[ "$...
4
Solved
I want to direct the output of a printf in a bash script to stderr instead of stdout.
I am not asking about redirecting either stderr or stdout from where ever they are currently routed. I just w...
Underexposure asked 9/6, 2012 at 18:48
5
Solved
How do i replace the \r?
#!/bin/bash
...
# setup
if [[ $i =~ $screen ]]; then
ORIGINAL=${BASH_REMATCH[1]} # original value is: 3DROTATE\r
AFTER =${ORIGINAL/\\r/} # does not replace \r
myThird...
3
Solved
This code can read all lines in the file.txt except the last line any ideas why.
while read p; do
echo $p
done < file.txt
2
Solved
Are there some more Text User Interface (TUI) frameworks for bash (other than this)? : http://code.google.com/p/bashsimplecurses/
I want to take user input (data entry)
process the entry
2
Solved
I'm writing a script in bash and I want it to execute a command and to handle each line separately. for example:
LINES=$(df)
echo $LINES
it will return all the output converting new lines with s...
4
Solved
I'm unable to get a pattern to match properly using regex in bash 4.1. I've read some information on about differences in quotes vs not quotes but I don't think that is my problem.
My goal ...
2
Solved
bash4 looks good on paper, and I think I'll build it and give it a test drive.
In the meantime...
Anyone who has done the same care to share their expierence?
It would be particularly interestin...
1
Solved
I put the following unsuccessfully to my .bashrc
shopt -s globstar
I am trying to test the command in action by
ls **/*.c
and by comparing it to
ls */*/*.c
How can you enable globstar in B...
1
© 2022 - 2024 — McMap. All rights reserved.