Add an extra line to a text file after each N lines

Hi I have a Unix command that produces a list of ip addresses along with other columns information . i want to add something to the command so that it displays it as a set of 3 lines then a space or ---- and then the next 3 lines and so on. how can I

Remove CRLF from the middle of a file

I have been receiving a text file where each row should be 246 columns in length. For some reason an errant CRLF is being inserted in the file after every 23,036 characters, causing all sorts of problems. The file is in a windows format, all line end

Unix script to remove the last seven characters of a variable

Need to remove the last seven characters from a variable. For example if my variable string is COLUMN_NAME||','|| then it should output COLUMN_NAME I have tried the below but last pipe symbol only getting removed var=$(lastline%|) var=$(lastline%|*)

simulating & ldquo; ls -l | sort -r & rdquo; using C-pipes

This is an assignment so I will not ask specifics. For this part of the assignment, I need to use pipes to "pipe" sort -r to ls -l. I know how to do execl, but I can't fathom the idea of what it means to pass "output of an execl" to an

How to redirect stderr to stdout and stderr itself

what I want to do is that redirect stderr to stdout without changing output of stderr. say, command has output in stderr, I want to out put all in stderr to screen while also handle the infomation through grep and save it to a variable. I tried line=

Dd does not work properly?

I'm not too familiar with Linux so please forgive the ignorance. I'm trying to dump a file to a virtual floppy disk using the command: dd if=a.out of=image bs=1024 count=1 conv=notrunc It creates the image file with the exact same size of a.out (1kB)

Use --getopts to pick up entire flags

Can getopts be used to pick up whole-word flags? Something as follows: while getopts ":abc --word" opt; do case ${opt} in a) SOMETHING ;; ... --word) echo "Do something else." ;; esac done Trying to pick up those double-dash flags.http

Writing a Unix-based operating system

So I was doing research on operating systems because I'm working on my own. I had heard about Unix a few years ago. I never really knew how much it influenced modern day computers until I saw this photo. Then I learned that parts of it were used in o

Divide a file into multiple outputs

I am trying to divide a big file into different files containing single information for each variable inside the file. my input file look like this: #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT PID008SM ...info here 1..... #CHROM POS ID REF ALT QUAL

How to get a return value from a Java class on UNIX

Please suggest a way to get the return String from my class in UNIX. This is my sample class: package com.mytest.package.main; public class DateExtractor { public static String getDate() { return "20120924"; } public static void main (String[] a

NASM programming, a starter guide?

I am interested in programming assembler for Intel x86 architecture and on Linux. After some initial research this lead me to believe out of FASM, NASM and MASM I wanted NASM. From this point on, how easy is it to write a NASM assembler "text file&qu

awk swap the first two fields gives a weird bug

I'm playing with awk and I'm trying to swap the first two fields of a file, like so: awk -F : '/cjares/{temp=$1; $1=$2; $2=temp; print}' /etc/passwd However, the output is not right. These are the two outputs, one without swapping the fields, the sec

How to copy a lof or small file into a folder at once?

How to change your implementations if you have to move a lot of small-size text files in the same directory by one go ? I think "mv" or "tar" can do this. Are there some better ways ? faster or reliable ? Thanksrsync is a widely popula

c ++ pipe: he is waiting for the writing

I use pipes to communicate between processes. When I write to a pipe, and I read it slower than I write, will write() block until the atomic write to the pipe is possible?Yes, at least if the number of bytes being written is smaller than the number g

see the file from bottom to top

HI, I know that cat prints the contents of the file on screen. i never worked on linux.But i am aware that tac is the command to show the file from bottom to top.I am not even sure whether tac is on unix.Atleast on my unix box its not present. i want

How to make the full disk quota

I am in a situation where i have to test mv(1) command while disk quota is exceeded. Can anyone let me know the steps to create this.. i mean how can i make disk quota full on normal Unix test machine. Thanks. dd if=/dev/zero of=/home/usverg/test bs=

How do i say what kind my shell is

How can I tell what type my shell is? ie, whether it's traditional sh, bash, ksh, csh, zsh etc. Note that checking $SHELL or $0 won't work because $SHELL isn't set by all shells, so if you start in one shell and then start a different one you may sti

How to display a log file generated by screen (screenlog.0)

So I just found out I can create log files of everything I do in screen (C-a H). Sounds like a nice way to keep track of potential goofs in a particular screen session. However, when I went to try it out the logfile is reported as being a binary file

Why does open () create my file with the wrong permissions?

I am trying to read some text from a file and write it to another using open(), read() and write(). This is my open() for the file-to-write-to (I want to create a new file and write into it): fOut = open ("test-1", O_RDWR | O_CREAT | O_SYNC); Th

lsof survival guide

lsof is an increadibly powerful command-line utility for unix systems. It lists open files, displaying information about them. And since most everything is a file on unix systems, lsof can give sysadmins a ton of useful diagnostic data. What are some

How can I generate Unix timestamps?

Related question is "Datetime To Unix timestamp", but this question is more general. I need Unix timestamps to solve my last question. My interests are Python, Ruby and Haskell, but other approaches are welcome. What is the easiest way to genera