This question already has answers here:
Batch string replace
(3 answers)
Closed 6 years ago.
i'm new to batch programming but i cant find how to manipulate string in a specific manner like we would do in C++.
i want to create a batch file which would change.
00:1E:90:75:9F:9F
to
001E90759F9F
maybe you can try this:
sed 's/00:1E:90:75:9F:9F/001E90759F9F/' your_file_name
Related
This question already has answers here:
When to wrap quotes around a shell variable?
(5 answers)
Bash arbitrary glob pattern (with spaces) in for loop
(2 answers)
Closed 2 years ago.
I'm trying to read a bash array file by file but for files with spaces in them, it comes out as two separate files. How would I solve this?
file names:
file A
fileB
file_C
the output Im getting is like this
File
A
FileB
File_C
What Im trying to do is to get File A on one line
I know I can read the array at once but for now we need to do it with a for loop since we're gonna be doing operations to it later in the loop.
for i in "${array[#]}"; do
echo "$i"
done
This question already has answers here:
Using `read` system call on a directory
(2 answers)
Linux C read a directory
(2 answers)
Closed 3 years ago.
It's possible to read a regular file or a symbolic link file ( not the file it's pointing to ).
Is there a way to read the content of a directory file in a file reading fashion (e.g. fread()) .
This question already has answers here:
How can I run an external program from C and parse its output?
(8 answers)
Closed 7 years ago.
I want to save the output from a bash script which is invoked from a C program to a variable declared in the C program. I searched and tried successfully calling a script using system, and I tried this, but it didn't work:
char* a;
system("a=`ls`");
printf("%s",a);
Use popen() system call. You can pass the cmd as the parameter. You will get the command output as text when the function returns. Hope this helps.
This question already has answers here:
Multi-dimensional arrays in Bash
(13 answers)
Closed 9 years ago.
i have a script which get datas from a file, but some parameters have more values than just one.
How can i make that my bash script can read as example:
user[3][1]=test1
user[3][2]=test2
Actually i make:
for i in $(seq ${#lala[#]}); do
${user[$i]}
done
which works. I have try it with ${user[$i][$i]} and seq ${#lala[#][#]}) but i cant get it running.
The script must then work with just [$i] and [$i][$i].
Can please somebody help me out, thanks a lot!
Well you're using wrong language/script, since BASH doesn't support multi-dimensional arrays. Having said that you can store a delimited text in each element of array that you can further break into array inside a loop.
This question already has answers here:
How do I execute a command and get the output of the command within C++ using POSIX?
(12 answers)
How to run a bash script from C++ program
(5 answers)
Closed 8 years ago.
How might I go about writing a program in C that executes a .sh (shell script) file? I'm writing a program, and one of the functions requires running some shell scripts. Thanks!
Use the system function
system("myscript.sh");