Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm trying to create a bash script that uses info pulled from Wikipedia via curl to help sort my music collection. I've gotten it to reliably return the information I want, but because of Wikipedia's formatting, there is sometimes information I want to discard. It is also not always formatted consistently; sometimes it is on multiple lines, and sometimes only one, but the information I want is consistently delimited between "[[" and "]]". I want to keep only the text between [[ and ]] and ignore the rest. All of the solutions I've found so far use sed and rely on consistent formatting. Basically what I want to do is take a long string formatted:
{{[[abcd]]efgh[[hijk]]lmno
[[pqrs]]
[[tuvw]]yz}}
and create an array with the values
abcd
hijk
pqrs
tuvw
With GNU grep and a Perl-compatible regular expression (PCRE):
grep -Po '(?<=\[\[).*?(?=]])' file
Output:
abcd
hijk
pqrs
tuvw
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
So a user can input this in the bash script when ask: 1,2,3,4,5,6 comma separated.
Now what I wanted is to append and repeat it with the string so the results would be like:
hi1 hi2 hi3 hi4 hi5 hi6
This works with:
"hi"{1,2,3,4,5,6}
The problem is using the user input to the loop to be used as the parameter to it. I tried using this but it does not work.
"hi"{$USERINPUT}
I do not have deep experience with bash to know this part.
Using bash pattern substitution and printf:
printf "hi%s " ${USERINPUT//,/ }
printf does not require a loop and prints as many strings as there are arguments.
The bash substitution is ${parameter/pattern/string} which is documented in the bash man page.
How about using sed?
$ echo "$USERINPUT" | sed 's/[0-9][0-9]*/hi&/g;s/,/ /g'
hi1 hi2 hi3 hi4 hi5 hi6
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have own script in C for linux, it is working with string loaded from file. I compiled on server gcc -pthread -o pipeline pipeline.c. It is working. Now I am running this script any like this ./pipeline UPPERCASE LOWERCASE < my_file.txt. I can read all arguments but I dont know how to read file name behind < in this script. It is possible, or how is it working?
The contents of that file will show up on your process's standard input (stdin). You don't get the name of the file, as the same interface will be used in situations where there's no filename, such as when the output of another process is piped to yours (doSomething | pipeline UPPERCASE LOWERCASE), or when the user's terminal is used for input by default.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
here I have three ways to get an H264 file, like all forensic scientists, I am very curious about the differences between them:
1.
ffmpeg -i video.mp4 video.h264
2.
ffmpeg -i video.mp4 -vcodec copy -an -f h264 video.h264
3. Using the example "demuxing_decoding.c" provided on the ffmpeg official website:
http://ffmpeg.org/doxygen/trunk/demuxing_decoding_8c-example.html
Obviously, the first one does the transformation, and the second one does the demuxing. They render different H264 files which however have similar file sizes(in my case, it's about say 24 MB). Suprisingly, the third one, which is also supposed to do the demuxing job, renders an H264 file with 8.4 GB! Why?
What I wondered is really, how the interiors of these three methods work?(The third one is already in source code, therefore it's quite easy to have an insight) What about the first two commands? What APIs are called when executing these two commands and how those APIs are called(namely, in what kind of sequences they are called) and things like that.
One thing that is also important to me is, i have no idea how I can trace the execution routines of ffmpeg command lines. I want to see what's going on behind ffmpeg commands in source code version. Is it possible?
I appreciate any comment.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a problem, I have a file with some number delimited by "". For example "125" etc.
An example of the file is:
10.0.0.0 11.0.0.0 "1200"
10.0.0.1 11.0.0.0.1 "200"
11.0.0.1 11.0.0.2 "320"
I use AWK for take the data but my problem is that I have to take only the integer value of the third column without "" because after I need to have some calculation with this numbers.
The solution is good also in C language.
Someone can help me?
Thanks
In awk, you'll have to strip off the quotes manually
$ echo '"2134"' | awk '{gsub(/(^")|("$)/,"",$1); print $1+2}'
2136
Obviously, this is not a C answer.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
By using the man command I want to list the names of the files I have already created with extra information such as filesize, date of modification etc.
I know I have to use the man command possibly something like:
man ls | documents
But this would not seem to work. If anyone would know how to do this that would be great? Any help would be much appreciated.
You use man to read the contents of the manual, not list files.
Use ls to list your files.
Use ls -l to list files with extra information.
Use ls -la to list all files (including hidden) with extra information.