I am trying to write an awk script that accepts -L as an argument. As an example to show you what I want, here is a simple awk script called awktest: If I run this from shell: I get as output: Which is what I expect. It seems to work for anything I put in except -L. If I run:
Tag: shell
How can I insert spaces or characters every “n” spaces while tailing a file?
I am tailing a log file and want to make it more readable. The current output is something like this: I want the output to be more like this: It would be great if sed could be used to insert the spaces. The spaces need to be every 8 characters — it will always be in binary data after the
How we can use correctly pipe in Linux?
I have a project, the goal it is to extract phone numbers of a data.txt file, so I did a program. Like that : My problem is when I want to use this program and to execute on my terminal I had to use pipe for my terminal command. I tried many different commands on my terminal and the last
print the count of files for each sub folder iterativly
I have the following folder structure: Similarly, Now, each folder from 00 to 23 has many files inside, which I would like to count. If I run this simple command: ls /A/B/C/D/E/00 | wc -l I can get the count of files in each of these sub directories. I want to automate this or get it iteratively. Also, the final
Unix – Replace column value inside while loop
I have comma separated (sometimes tab) text file as below: parameters.txt: with below code I try to loop through the file and do something I wanted to update the last column of the file to N if the above operation is successful, however below approaches are not working for me: sed ‘s/$f5/N/’ ‘$5==”Y”,$5=N;{print}’ $(echo “$line” | awk ‘$5=N’) Update: Few
Why dd can’t handle sparse files in shell scripts? [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 4 years ago. Improve this question
IF statement for different lines [closed]
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 4 years ago. Improve this question Question is simple, but I can’t find a fast and elegant way to solve. I want to decide next: if block size of files is
List and change directory and run command in Shell
I am coming back to shell after almost 6 years or so. I have a directory structure let’s say, MainDirectory –> subDirectory1/some.xml –> subDirectory2/some.xml … … –> subDirectoryN/some.xml And I want to execute some.xml in all the subdirectories and get the output to a file using “>” operator I guess. What would be the proper script for this? I tried
Copy fails in bash script even when I use `/bin/cp` and chmod 777 on the file
I wrote a bash program to setup new Debian install’s…. but I can’t figure this problem/error out…… I can’t get it to copy a .bashrc file to a new users /home directory even with 777 permissions. Here are the declarations and setting of the variables: Here are the files the program uses and they are in the same directory the
How to merge two rows in a same row from a text file in linux shell script
From Nagios I downloaded its html file by using wget command and then I converted that htmlfile to Textfile by using following code: then I cut the first 10 lines becoz I dont want that text and I got below textfile output I have to merge two rows into single row not for all lines only for particular output from