4
votes
3answers
104 views

Frequency of words in non-English language text: how can I merge singular and plural forms etc.?

I'm sorting French language words in some text files according to frequency with a focus on insight rather than statistical significance. The challenge is about preserving accented characters and ...
0
votes
4answers
26 views

Bash one liner to change configuration parameters

I have a config file with following structure. ValueOne = 1 ValueTwo = 2 ValueThree = 3 I want a one liner bash script to find ValueTwo and change the value to 22222. Any idea? Not School Thing
0
votes
1answer
37 views

Parse lines of output from bash loop

I'm trying to parse the output of commands run in a bash loop. Here is an example: $ for i in `git log --format='%H'`; do echo $i ; git branch --contains $i; done | head -n 8 ...
3
votes
1answer
61 views

Convert json numbers to strings in the shell

When parsing json, the command-line tool jshon converts numbers to scientific notation, and sometimes tries to round them. To avoid these problems, I want jshon to consider these numbers as strings. ...
5
votes
3answers
208 views

How to extract URIs from files

How can I extract from a certain number of files all the URIs like magnet: file:? I'd like to have one URI per line as the output. I'd like to use bash to achieve this, but any suggestion is welcome. ...
3
votes
2answers
100 views

Can we find page count of a file in Unix/Linux?

I want to count number of pages in the file /var/log/messages, so that I can use pr command to start printing from the page I want to. For example, suppose that /var/log/messages file contains 300 ...
2
votes
2answers
32 views

Merging files by rows

Is it possible to copy the whole rows of File1 in a new File3 following the instruction given by File2 by using a simple bash script using sed or awk? File1: /*two or more columns*/ AC 456324 DC ...
2
votes
1answer
58 views

merge csv files by first column

I have 3 csv files like this. csv 1: 1,aaaa,bbb,2014-04-01 2,qwe,rty,2014-04-03 3,zxc,cvb,2014-04-05 csv 2: 2,j,k,2014-04-01 3,a,s,2014-04-04 5,g,h,2014-04-08 csv 3: 2,a,s,d,f,g,2014-04-01 ...
2
votes
2answers
55 views

Removing lines with a single common field

I have a tab separated file that looks like this: 123 some text 123 some different text 334 some other text 341 more text and I want to do two things. One is to order everything numerically ...
4
votes
3answers
184 views

How can I delete a trailing newline in bash?

I'm looking for something that behaves like Perl's chomp. I'm looking for a command that simply prints its input, minus the last character if it's a newline: $ printf "one\ntwo\n" | ...
2
votes
2answers
123 views

Printing lines with similar text together

I am currently working on analyzing the performance of an application. I've starting by looking at the logs generated by our application and identifying the business logic tasks that are taking more ...
2
votes
1answer
36 views

Extracting lines around keys from a file

I have a large file with around 15 million lines. The odd lines contains the keys (but not only the keys) and the even lines are the data. That is, the file is something like: WRTZ Tyrosine ...
5
votes
2answers
193 views

Shell script (bash) to add or replace the license text contained within .c , .h and makefiles?

I have a set of *.c , *.h and Makefiles in a folder where some files contain the license text and some files don't have any license text. So I need a shell script where I can add license text if the ...
2
votes
1answer
28 views

set flag to remove duplicate records from a file based on some values of the record

I have a file having the following records (pipe delimited): SK200-10|ALBUMIN-SK|INS|SEKURE ALBUMIN 2 X ...
1
vote
1answer
57 views

Fastest way of find and replace in large file with replacing filed present in another file

I have two files. File1 is a csv with 60 fields: 111,Check1|^/h1/h2/h3,22062014184500,20,0..... 111,Check2|^/h43/h40/h9,22062014184500,4,..... 111,Check3|^/h1/h3/h4,22062014184500,0,0,..... File2 ...
1
vote
7answers
81 views

Get text between two special characters in a line using shell

I have a line which comes from a file via: cat aaa.txt | grep "HIJK" Output gives: HIJK="My name is HIJK" I need to get the text My name is HIJK into a variable in a shell script. I have tried ...
3
votes
6answers
68 views

Collapse some repeated parts of successive lines

I have data in notepad like this: 4480-1 4480-2 4480-3 4480-15 4581-1 4581-2 4581-3 4581-4 Can we do it using for loop sort of things? With sed? My required output is ...
0
votes
2answers
35 views

names that occur the largest number of times in a data set

users directory ---------------------- hjsyeh hellodir ; awgshd newdir; hjsyeh hidir; jkdhjk welcomedir the above given are set of users and the directories they created .How can I ...
2
votes
2answers
169 views

How to parse multiple string patterns in linux shell script

I am new to linux shell and I had a hard time thinking of the solution to this. Can somebody help how to parse multiple strings (data) in a file? For below file, I want to parse all the values next to ...
6
votes
3answers
67 views

Print a multiline variable in a column

I have a script that collects values from a cluster. The values, in some cases, have multiple lines. I have a printf format that specifies how the data should be positioned however, it doesn't take ...
-1
votes
3answers
70 views

Checking if line in file exist

I have a bash script which asks a user for the number of CPU cores and saves it to variable named $cores. Now I want to add this variable to .bashrc, so I ask user how much CPU cores he has and then ...
0
votes
2answers
98 views

How to get the value from rows and columns from text file in bash?

I am working on a bash project. I need to get all the values (one at a time because I will be using them somewhere else) from a text file. The text file I will be getting is structured like this: ...
1
vote
1answer
55 views

Editing INI-like files with a script

I'm writing a script to automate setting up Puppet agent configuration files in Docker. Basically, I need to ensure that the following section is in /etc/puppet/puppet.conf: [agent] ...
3
votes
5answers
112 views

Get values block by block in same file

I have a file say "SAMPLE.txt" with following content, P1 10,9:6/123456 P2 blah blah P1 10,9:5/98765 P2 blah blah P1 blah blah P2 I want a output file say "RESULT.txt" as, Value1:123456 ...
0
votes
1answer
51 views

Search a string between two timestamps starting from bottom of file

I was trying to find a string Cannot proceed: the cube has no data in huge test.txt file only between timestamps yesterday 22:30 pm to today 00:30 am. Script: tac test.txt | awk -v today=$(date ...
1
vote
3answers
237 views

compare two columns of different files and print if it matches

I am using solaris 10 and Grep options involving -f doesnt work . I have two pipe separated files: file1: abc|123|BNY|apple| cab|234|cyx|orange| def|kumar|pki|bird| file 2 : abc|123| ...
0
votes
3answers
200 views

compare two files based on a column and print it

I have two big files of 400,000 lines. I want to compare the column 1 of the second file with column 1 of first file recursively. If they match I would like to print the whole line. It is a sorted ...
1
vote
1answer
125 views

Shell script and crontab to capture file size, name and date in a CSV file and then send via email?

I have a number of zip files in a certain folder. I want to capture file name and the size of the files in a CSV format in day wise and put it in crontab so I can report on a daily basis, and then ...
3
votes
4answers
281 views

how can we use awk to get multiple words after a significant word?

I want to connect to my DB only once to do multiple SELECT queries as follows: #!/bin/bash #Begin Code query=$(echo "SELECT COUNT(*) from USER_IPTable; SELECT User from USER_IPTable; ...
6
votes
10answers
518 views

Copy only Specific text of a file to another

I have a file abc.txt the contents are <classpathentry kind="src" path="Sources"/> <classpathentry kind="con" path="WOFramework/ERExtensions"/> <classpathentry kind="con" ...
4
votes
3answers
143 views

conditional coloring in grep

I have a simple bash script. One line of my script matches a "pattern" with grep and colors the match grep -i --color=always -- "$1" I need to modify it, so that it only colors the match, if the ...
1
vote
2answers
78 views

Create file with specific formatting from directory contents

I am using Solaris and csh. In $home/test there are five files: a.txt, b.txt, c.txt, d.txt and e.txt. If I run % find $home/test/ -type f -print > ../filenames.txt that file will look like: ...
2
votes
1answer
70 views

cut slice of file based on time when lines are written

i have a process running always with logging file could reach up to 5 giga, sometime i have to take slice of this log based on interval of time (usually i used dd). is there any command in linux to ...
10
votes
2answers
805 views

Simplest way to comment/uncomment certain lines using command line

Is there a way to comment/uncomment a shell/config/ruby script using command line? for example: $ comment 14-18 bla.conf $ uncomment 14-18 bla.conf this would add or remove # sign on bla.conf on ...
2
votes
2answers
73 views

Sed? Stripping all formatting, i.e line breaks and whitespaces, from a report text file, while masking out certain pieces

I am working on a project in which I need to remove all formatting from a text file including whitespaces and line breaks, then replace any colons with pipes. I've made some headway but I cannot find ...
7
votes
5answers
391 views

List out strings which are substrings of other strings in the list

I have a list of names like so: dog_bone dog_collar dragon cool_dragon lion lion_trainer dog I need to extract out names that appear in other names like so: dragon lion dog I looked through the ...
4
votes
7answers
318 views

How can I groups numbers in a file

I have a file with numbers in float format. I can review them via sort -rn numbers.txt | less I would like though to be able to "group" them. I.e. easily see how many are in the same range. To give an ...
0
votes
0answers
69 views

Editing metadata with bash

I have a bunch of photos(jpeg, bmp, png) that I have arranged in such a manner that the metadata is in html form in a separate file. I would like create some script to read this html file and edit ...
1
vote
2answers
105 views

Issues Splitting CSV files

Im trying to split a csv file into multiple files using the below command..This command splits into 5 files but the data is truncated in one of the file? How do I fix this issue? >>split -n 5 ...
1
vote
2answers
138 views

Remove just one word before pattern match in shell script

Input: int foo(int a, void * b, int c); Output: int foo(int, void *, int); Want to use "," as pattern to match. If "," pattern is matched then remove the previous word i.e. a, b & c.
2
votes
2answers
43 views

How to format textutil -excludedelements

I use Geektool on the Mac to display various information on my desktop. One feature of Geektoool is the ability to use shell mode to launch custom scripts or commands. I am not versed in any type of ...
2
votes
3answers
654 views

Replacing the values in one file with the values in another file in bash

I am having a csv file naming List.csv in following format: Location,IP Address,Host Name,Domain,Domain Name, User Name,Manufacturer,Model,System Type, Serial Number, Operating System,RAM ...
1
vote
5answers
252 views

Replacing backslashes with commas in Bash

I tried writing a script in which I am reading through a file line-by-line. I am supposed to replace a backslash (\) with a comma (,). The input file is as follows: 1,2,3,WORKSTATION1\A,5 ...
1
vote
1answer
36 views

insert value at the end of every record based on unique IDs

I have 2 files , one with Delimited and other one is Positional file. These two files shares same unique ID's as shown below but both the files contains different information. del.txt ...
4
votes
3answers
145 views

Make a directory for each row within the given text file?

I'm trying to write a bash shell script that will read the data from a given (as an argument) file, and for each row in the file, make a sub-directory under the given (as an argument) directory. The ...
1
vote
2answers
724 views

Editing a Java properties file with Bash

I have the following Java properties file that is maintained by humans. # file.input = /very/old/name # file.input = /old/name file.input = /current/name file.input.default = /default/name ...
1
vote
2answers
145 views

Bash: split list of files into different files?

I have several files in a directory like: data1.dat data2.dat .... data24678.dat To run another code, I need to have a text file with the names of the files but I need to split in 50 files per ...
3
votes
1answer
63 views

Find and Replace Recursive

I want to modify every file in a directory recursively. I want to replace: <?php with <?php /** * * Copyright (C) MyCompany, Ltd. - All Rights Reserved * Unauthorized copying of ...
2
votes
3answers
72 views

How to optimize this oneliner? (if second column empty, put the line in another file)

I have a little "oneliner": while read ONELINE; do if [[ -n "`echo $ONELINE | awk '{print $2}'`" ]]; then echo "$ONELINE" >> LIST-ok.txt else echo "$ONELINE" >> ...
5
votes
1answer
145 views

counting multiple patterns in a single pass with grep?

I've written a grep loop to iteratively count DNA trinucleotides within a gzipped DNA fasta file containing DNA sequences e.g. declare -a tri=(AAA AAC AAG AAT CAA .. etc) for i in ${tri[@]} do ...