Skip to content
Advertisement

Tag: file

Editing single value in file in C efficiently

I have a C program that currently edits a single value in a parameter file by using sed through a system call. I’d like to change the program to use the C file libraries to edit this value, but the only way I know how to do this is by reading in the entire file, changing the value, and rewriting

How to replace lines that contains integers by using sed

I have a file that contains two fields. The first field may or may not contain an Integer. If it contains an integer and a dot follows the integer I would like to manipulate part of second field. So As an example: I couldn’t make it since I have very limited knowledge in regex. I would be very appreciate if

Why Sed cannot replace lines that contains . + and *

I have a large file and some of the lines are as follows: I want to replace ….+UNKNOWN part with the …+PUNCT To do that, I did the following: However, none of the lines gone. I couldn’t find my error, could you help me about ? Answer In some versions of sed, + has a special meaning, use + to

Overwriting TS Stream File with FFMPEG in Linux

I’m trying to convert rtmp streams to m3u8 stream. To reach that aim I use FFMPEG. Now, there is no problem with converting and downloading. However, it writes lots of .ts file such as channel0000.ts,channel0001.ts,channel0002.ts. Per every 10 seconds, 1 ts file is created. In this point, I want a single ts file. In other words, I need overwriting because

Copy numbered image files where number is less than X

I have a folder of 10,000 JPEg’s labeled 1.JPG to 10000.JPG. I want to copy all files that have a number less than (or greater than) X to another directory. What’s the best way to do this from the command line? Answer A simple brace expression would zap this, here I am guessing at your number range of course: More

How to edit a big file

Imagine a huge file that should be edited by my program. In order to increase read time I use mmap() and then only read out the parts I’m viewing. However if I want to add a line in the middle of the file, what’s the best approach for that? Is the only way to add a line and then move

Linux file descriptor – getting current redirection stdout file?

I’m trying to get the current stdout redirection, and having some trouble. I have a script that is always run with stdout redirection ie: In myscript.sh, I need to find out what file it is being output to. I’m trying this currently (not working): That’s outputting logfile = /tmp/sflq.r3f, for instance. I need to instead find that it’s going to

Advertisement