Skip to content
Advertisement

Deleting the first row and replacing the first column data with the given data

I have the directories name like folder1,folder2,folder3….folder10. Inside each directory there are many text files with different names.And each text files contain a text row on the top and two columns of data that looks like as below

JavaScript

Then what i want to do is== at first i want to remove completely the first row of all text files present inside the directories folder1,folder2,folder3….folder10.After that whatever the value in the first column of each text file present inside the directories, i want to replace that first column values with other values that is saved in separate one single text file named as “replace_first_column.txt” and the content of replace_first_column.txt file looks like as below and finally want to save all files in the original name inside same directories.

JavaScript

I tried the code below: but it doesnot work.Hope i will get some solutions.Thanks.

JavaScript

Advertisement

Answer

Something like this should do it using bash (for {1..10}), GNU find (for + at the end) and GNU awk (for -i inplace):

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement