The simplest way to display file contents is using the cat
command:
cat file.txt
I can get the same result using input redirection:
cat < file.txt
Then, what is the difference between them?
The simplest way to display file contents is using the cat
command:
cat file.txt
I can get the same result using input redirection:
cat < file.txt
Then, what is the difference between them?
From a given a file, I have a requirement to create a copy that is padded with zeros to a specific size.
If you create a file with the following.
echo test >testfile
The output of the following command is inconsistent.
cat testfile /dev/zero | dd bs=256k count=1 status=none | od -c
This is the output that I would expect.
0000000 t e s t \n \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
1000000
But you also randomly get either of the following.
0000000 t e s t \n
0000005
0000000 t e s t \n \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
0400000 \0 \0 \0 \0 \0
0400005
Why does this command have inconsistent behavior?
Even if dd is cutting the pipe off at the end of the first file, The 128k result is strange. I get the same inconsistent results under 16.04, 18.04 and 19.04 systems.
I have several videos in a folder;
~/Downloads/movie1.mkv
~/Downloads/movie2.mkv
~/Downloads/movie3.mkv
I would like to extract the bitrate for each file, and output the data into a single text file, or output list which I can copy and paste into a text file.
I have installed ffmpeg.
So, for example, the output of ffmpeg -i movie1.mkv
is;
Metadata:
encoder : libebml v1.2.0 + libmatroska v1.1.0
creation_time : 2011-04-09T18:18:05.000000Z
Duration: 00:04:27.71, start: 0.000000, bitrate: 10698 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1038, SAR 1:1 DAR 320:173, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
title : movie1
Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Metadata:
title : DTS-ES 5.1 @ 1509 Kbps
Stream #0:2(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
title : Commentary
Stream #0:3(eng): Subtitle: subrip
Stream #0:4(eng): Subtitle: subrip
The "bitrate: 10698 kb/s" is the crucial part I am after here.
Let's pretend all three movies have the same bitrate.
I would like to extract the bitrate information from all three videos, and have them output as;
movie1.mkv 10698
movie2.mkv 10698
movie3.mkv 10698
How would I go about extracting and outputing this information in bulk?
I've been trying a combination of finding by file name, ffmpeg, and then | to grep. e.g ; find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | grep "bitrate:"
Current attempts;
The command
ffmpeg -i movie1.mkv 2>&1 | grep bitrate | sed 's/bitrate: \(.*\), kb/\1/g'
returns
Duration: 00:04:27.71, start: 0.000000, bitrate: 10698 kb/s
The command
find . -name "*.mkv" -exec ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "${~/Downloads/1%.mkv}" ';`'
returns
~/Downloads/1%.mkv: No such file or directory ~/Downloads/1%.mkv: No such file or directory ~/Downloads/1%.mkv: No such file or directory
I feel that I'm close here, and that there's just something wrong with the find and recalling the output of find into ffprobe.
As the question says, I need to edit my /proc/acpi/wakeup
file, but when I open it with any text editor, it shows blank file. cat
command, on the other hand, displays correct file contents in terminal. When I navigate to that file in file manager, it says it's size is 0 bytes. I'm using Xubuntu 15.04. I'm thoroughly confused.